Let’s know about the Python Shell and idle

Categories: Python

 Let’s know about the Python Shell and idle 

 

Python is an interpreted language, which means you just type in plain text to an interpreter, and things happen. There is no compilation step, as in languages such as c or FORTRAN. To start up the Python interpreter,just type python from the command line on climate. You’ll get a prompt, and can start typing in python commands. Try typing in 2.5*3+5. and see what happens. To exit the Python interpreter, type ctrl-d.

Eventually, you’ll probably want to put your Python programs, or at least your function definitions, in a file you create and edit with a text editor, and then load it into Python later. This saves you having to re-type everything every time you run. The standard Unix implementation of Python provides an integrated development environment called idle, which bundles a Python interpreter window with a Pythonaware text editor. To start up idle, log in to the server from an xterm and type IDLE. You will get a Python shell window, which is an ordinary Python interpreter except that it allows some limited editing capabilities. The real power of idle comes from the use of the integrated editor. To get an editor window for a new file, just choose New Window from the File menu on the Python Shell window. If you want to work with an existing file instead, just choose Open from the File menu, and pick the file you want from the resulting dialog box. You can type text into the editor window, and cut and paste in a fashion that will probably be familiar to most computer users. You can have as many editor windows open as you want, and cut and paste between them. When you are done with your changes, select Save or Save as from the File menu of the editor window, and respond to the resulting dialog box as necessary. Once you have saved a file, you can run it by selecting Run module from the Run menu.

 

You can actually use the integrated editor to edit just about any text file, but it has features that make it especially useful for Python files. For example, it colorizes Python key words, automatically indents in a sensible way, and provides popup advice windows that help you remember how various Python functions are used. As an exercise at this point, you should try creating and saving a short note (e.g. a letter of gratitude to your TA), and then try opening it up again in a new editor window. To exit from idle just choose Exit from the File menu of any window.

An especially useful feature of the idle editor is that it allows you to execute the Python script you are working on without leaving the window. To do this, just choose Run Script from the Edit menu of the editor window. Then the script will run in the Python shell window. When the script is done running, you can type additional Python commands into the shell window, to check the values of various quantities and so forth.

IDLE has various other powerful features, including debugging support. You can manage without these, but you should feel free to learn about and experiment with them as you go along. Once you have written a working Python script and saved it,say, as MyScript.py, you can run it from the command line by typing python MyScript.py. There is no need to start up IDLE just to run a script.

 

Top Blogs
Interview Question and Answer of Python Published at:- Basic Concepts of Python Programming Published at:- Learn Python Programming Language Published at:- Let’s know about Python basics Published at:- Let’s know about the Python Shell and idle Published at:- How to running Python Locally Published at:- What is Lists, tuples and strings in Python? Published at:- Some Modules In Python how to it works Published at:- Program control: Looping, conditionals and functions Published at:- Program control: Looping, conditionals and functions ( Part 2) Published at:- Top iOS interview questions for Beginners Published at:-
R4Rin Team
The content on R4Rin.com website is created by expert teams.