Python IDEs

Life is 10% what happens to us and 90% how we react to it. If you don't build your dream, someone else will hire you to help them build theirs.

Python IDEs

In this section, we are going to talk about the Integrated Development Environment, or IDE, of Python. Although you could just use any simple text editor, and there are more advanced IDEs available, Python does come with IDLE, which is the IDE that ships, by default, with Python. If you start the icon up, it will typically take you to the Python shell, where you could try out various statements, and see the results. You can also, from this, go to open up files that you, recently, have been working with.

Once you open up a file in the editor, you’ll be able to see any comments that you have in red, strings will appear in green, the keywords will be in orange, anything that is a definition that you create will be in blue, and the use of built-ins will show in purple. When you look at the output in the shell, you can see the same kind of color coding where, again, the use of built-ins is purple, but for standard output, it will be in blue. Standard error will be in red, and typically if you have standard input it would be in black.

Now through the use of Options, you can go to Configure IDLE, and there’s a number of different settings that you can change for the fonts, those colors and high lighting’s that you see, the shortcut keys, and other general settings. If you go to create your own new module, you do that with File menu, New File from either window. You can do that either from a text editor window or the Python shell. So now you can edit my program. If you want to see what the results of it are, you can use the Run menu, Run Module to execute that program. you have to save it each time you do this, but if you just click OK, you can save it wherever you’d like. you might go put that under Python34, in myscripts, and call this something like “test_ide.”

If you don’t specify .py, you’ll notice that it will add the .py, which is used for Python source code files. It restarted the shell and executed the statements within the program. And then you are left with your program to still interact with, if you want to. When you’ve got a couple different programs open, and your shell, you may find the Window menu useful for being able to navigate to the different open files. So you can go back to the abc window. Any particularly large file, with lots of definitions and classes and such, you can use the File menu to go do Class Browser, and be able to either browse through the definitions of those functions, or you can even find different classes, and then methods within those classes, to go browse to those. That Class Browser actually stays open, so if you put it in the right place on your screen, you can navigate a very large file very rapidly.

If you want to go find different modules, if you stored them in the Python path, then you can use File menu, Path Browser to go navigate those different directories, where you might have stored different modules, and then be able to open up those modules. Finally, you could also use File menu – Open Module, and type in the name of a module that’s on that Python sys.path, and it will locate that module and open that file for you. Of course, like most editors, the IDE also provides you a list of all your recent files, that you might have been using, and does typical file functions like being able to, as we saw, create new files, open existing files, save files, print files, of course close, or completely quit out of the program.

On the Edit menu, you’ll find your typical undo’s and redo’s, Cut, Copy, and Paste, as well as being able to go find, or replace, things. What can be helpful, when trying to type in something that might be a long definition, is to show completions. You also can see different call tips, although these will typically automatically appear as you’re typing in the window. Since indentation is important in Python, it’s critical that you’re able to select blocks of code, and either be able to indent, or as they say, “dedent” those blocks of code. You can also, if you’ve the bad experience of mixing tabs and spaces; “untabify” things. Or to make things only use tabs; “tabify” those selected regions.

Any time you see an asterisk (*) in front of your filename, you know that your file’s been modified. So if you went to try and go run that, it’s going to ask you to save that module. Fortunately, there are many levels of undo that you can use. In the editor, you can even undo all the way back to the unmodified state of the file, which of course is very helpful. Finally, we might mention the Help menu, where you can either go to find out help on IDLE, and different things about the Python shell windows versus how to start it up from the command line, and other kinds of extensions to the program. You also can get straight to the Python documentation under Help.

So if you’re trying to look up documentation for some particular module, for things that are built in, you might go to the Python Standard Library, and then find these different modules and the discussion of them, and how to use them; very helpful. Since IDLE is implemented in Python, even though it may not seem like you have any programs running, if you still happen to notice, in something like a Task Manager, that you see a Python process, don’t be too worried if you still have IDLE active on your screen, that’s Python running that IDLE process for you. As we will see throughout the rest of the videos, this IDLE environment will be used to edit and demonstrate the various different aspects of Python.