[Tutor] Python Idle Crashing

Steven D'Aprano steve at pearwood.info
Fri May 17 20:08:32 CEST 2013


On 18/05/13 03:16, bob gailer wrote:
> On 5/16/2013 8:49 PM, Alan Gauld wrote:
>> don't run programs on real data using IDLE. IDLE is for developing programs not running them.
>
> That is really scary. Why do you say that? The IDLE documentation does NOT say that!

IDLE is an IDE, that is, Integrated DEVELOPMENT Environment (emphasis added). It is for development, not a general shell environment like your normal operating system shell.

Like all IDEs, IDLE is one extra layer between your code and the machine actually executing code:


Your Python source code
*** The IDE ***
The Python interpreter
The operating system
The hardware

IDLE does make some changes to the Python environment. In principle, none of the changes should be detectable, or at least not meaningful, but sometimes they do have visible effects. For instance, in my "vanilla" Python environment:


[steve at ando ~]$ python -E
Python 2.7.2 (default, May 18 2012, 18:25:10)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print u"฿"
฿
>>>


while here is the same result in IDLE:

Python 2.7.2 (default, May 18 2012, 18:25:10)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> print u"฿"
฿
>>>

Oops, IDLE has just played silly-buggers with the encoding of the (pseudo-)terminal, and consequently has not printed the Unicode character correctly.

Another example: if you raise SystemExit, the vanilla Python interpreter exits, as it is supposed to. But IDLE merely prints a traceback, then continues without exiting.

In a nutshell, while you *can* run code "live" in IDLE, as soon as you hit a bug or mysterious behaviour, you should always try running it without IDLE and see if the problem goes away.



-- 
Steven


More information about the Tutor mailing list