473,320 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

difference between IDLE and command line

New to Python, and just had something strange happen.

I've been running my new code in IDLE running in windows. My IDLE
version shows as 1.2.1, Python version displaying in IDLE is 2.5.1.

I have been editing my code in UltraEdit then testing in IDLE by
choosing open, then F5. I didn't see an easy way to refresh in IDLE, so
each edit I've been closing the file (not IDLE itself), then opening
again. Since IDLE does not keep track of what directory I last opened
from, this gets tedious, so I decided to run my code from the command line.

Here's where it got interesting for me. From the command line, I'm in
the directory containing my source, I execute via "python mycode.py", I
receive an error in my code. Specifically, it's erroring because I have
a copyright character in a string that I am outputting via the
file.write method. The error has to do with no encoding declared.

What surprised me is that this code runs with no problems in IDLE.

Should I expect different execution behavior between IDLE and a command
prompt?

Oh, and executing python all by itself in the command prompt shows the
same version as what is displayed in IDLE.

Nov 2 '07 #1
2 5626
En Fri, 02 Nov 2007 13:38:07 -0300, Jim Hendricks
<ji*@bizcomputinginc.comescribió:
New to Python, and just had something strange happen.

I've been running my new code in IDLE running in windows. My IDLE
version shows as 1.2.1, Python version displaying in IDLE is 2.5.1.

I have been editing my code in UltraEdit then testing in IDLE by
choosing open, then F5. I didn't see an easy way to refresh in IDLE, so
each edit I've been closing the file (not IDLE itself), then opening
again. Since IDLE does not keep track of what directory I last opened
from, this gets tedious, so I decided to run my code from the command
line.

Here's where it got interesting for me. From the command line, I'm in
the directory containing my source, I execute via "python mycode.py", I
receive an error in my code. Specifically, it's erroring because I have
a copyright character in a string that I am outputting via the
file.write method. The error has to do with no encoding declared.

What surprised me is that this code runs with no problems in IDLE.
Since version 2.4, Python *requires* an explicit encoding declaration at
the start of the file, when it contains a string literal outside the ASCII
range (0 to 127). See
<http://www.python.org/doc/2.3/whatsnew/section-encodings.html>
That IDLE doesn't require an encoding (and assumes something, perhaps
latin-1, I don't know) is an unfortunate bug (already reported, I think).

--
Gabriel Genellina

Nov 3 '07 #2
Jim Hendricks wrote:
I have been editing my code in UltraEdit then testing in IDLE by
choosing open, then F5. I didn't see an easy way to refresh in IDLE, so
each edit I've been closing the file (not IDLE itself), then opening
again. Since IDLE does not keep track of what directory I last opened
from, this gets tedious, so I decided to run my code from the command line.
Tip: IDLE has a recent files list, under the File menu. Use Alt-f Alt-
r to access it quickly.

Tip #2: You can run a script in IDLE from the command line: IDLE -r
<script file>. This will open an IDLE shell, run the script in it, and
afterwards become interactive. Very useful for debugging etc.

- Tal
reduce(lambda m,x:[m[i]+s[-1] for i,s in enumerate(sorted(m))],
[[chr(154-ord(c)) for c in '.&-&,l.Z95193+179-']]*18)[3]

Nov 3 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Paul M | last post by:
Pythoneers, IDLE doesn't use the ps2 prompt ("..." in the command line interpreter) because it supports multiline editing. This issue has been discussed before, for example see Guido's...
16
by: Kerry Neilson | last post by:
For the past couple of months, Idle won't start when I invoke it. I am at a complete loss for why this is. When this happens, they python command line still starts, and python works fine...
6
by: Kevin Walzer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm looking for other peoples' viewpoints about their experiences with IDLE as an editor--what are its good points? What are its limitations? Any...
15
by: Ashot | last post by:
This is sort of both Python and Vim related (which is why I've posted to both newsgroups). Python related: ---------------------- I have been frustrated for quite some time with a lack of a...
13
by: John Salerno | last post by:
If I want to write my code in a separate text editor (I like UltraEdit) but then press a single button to have that code run in the IDLE environment, is that possible? I know that you can configure...
3
by: Rob | last post by:
I have Python 2.4.3 installed on Windows XP on both a real computer and a virtual machine under VMware. Just recently, IDLE stopped working. I would select IDLE from the start menu or right click...
3
by: writser | last post by:
hey all, For my study I'm writing a simple threaded webcrawler and I am trying to do this in python. But somehow, using threads causes IDLE to crash on Windows XP (with the latest python...
2
by: Russ P. | last post by:
Is it possible to pass command-line arguments when running a program in IDLE? The "Run" menu does not seem to provide that option. Thanks.
6
by: Andreas Tawn | last post by:
I'm trying to integrate the timeout function from here http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473878 into a long running automation script and the following code causes IDLE after...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.