Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

shell - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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'.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...