Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference Between Python's IDLE and its command line

What are the key differences between Python's IDLE and its command line environment? IDLE looks nicer, of course, and has some kind of GUI...

Moreover, is IDLE treated the same as the shell? I mean, the shell is the middle layer between the user and Python's interpreter?

like image 373
Donatas Avatar asked Sep 10 '15 09:09

Donatas


1 Answers

I am not sure what you question is, but here is a Windows-7 oriented answer of similarity and difference. In the start menu for Python x.y, you can select 'Python x.y (x bits)' to run python interactive in a text-line-oriented console window provided by Microsoft. The console handles key presses and mouse movements and clicks. When you hit , the console sends the line of text to python, which is waiting for input on sys.stdin. When Python processes the line, it sends output to sys.stdout or sys.stderr. This includes '>>> ' and '... ' prompts. The console displays the text for you to see.

In the start menu, you can instead select 'Idle ...'. Unless you have previously selected a different startup option, python run Idle code which uses the tkinter module which used tcl/tk to run a graphical user interface that somewhat imitates the console. The tkinter/tk gui handles key and mouse input and displays output. In both cases, some software besides the Python interpreter itself handles interaction between you and Python.

Some important differences:

  1. Cut, copy, and paste work normally. The Windows console is crippled in this respect.

  2. Idle colors input and output. The Windows console does not.

  3. Idle can display all unicode BMP (the first 64K) chars. The Windows console is limited by code pages.

For 1, 2, and 3, the console of other OSes may do as well or better than Idle.

  1. Idle lets you enter, edit, send, and retrieve complete statements. Interactive python with Windows console only works with physical lines.

Update, 2017/11:

Item 1 above: At least on current Win10, cut, copy, and paste work normally.

Item 3 above: At least on Win10, unicode works better in Command Prompt with 3.6+.

New item 5: The IDLE doc section, also available as Help => IDLE Help now has section '3.3. IDLE-console differences'.

like image 120
Terry Jan Reedy Avatar answered Oct 21 '22 12:10

Terry Jan Reedy