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. 2 5624
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
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] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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.
|
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...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
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)...
| |