vortisz.blogg.se

Editra command line
Editra command line












editra command line

#Editra command line code#

Finally, when an exception is raised with your debugger running, you can double-click the exception to jump directly to the code where the exception happened. If you happen to be using tkinter to create a user interface (UI), you can actually leave the mainloop() call off (which can block the UI) so you can debug your user interface. This can be useful in loops where you are trying to determine the current value of an item inside the loop, for example. However you can run a module with debugging turned on such that you are able to interact with your program’s objects. Sadly you cannot use the debugger in your main editing menu. That is nice for debugging, but only in the Shell window. Which reminds me you may have noticed that the main IDLE screen has a Debugger menu. You just go along slowly uncommenting out stuff until you hit your bug. Commenting out portions of it and re-running the script can help you figure out where you went wrong. One way it can be helpful is when you have a lot of code and you need to find out why it’s not working correctly. Commenting out your code can be very helpful. I find that pretty helpful when I’m testing my code. It has some helpful items for indenting and dedenting your code, as well as commenting out your code. The Format menu has lots of useful functionality. Finally, the Edit menu has some menu items that will show you various things, such as highlighting parentheses or displaying the auto-complete list. It also contains various ways to search your code and do a search and replace. The Edit menu has your typical features, such as Copy, Cut, Paste, Undo, Redo and Select All. Note that you won’t be able to load the Class Browser unless you have actually saved your program. You’ll find it helpful when you have lots of lines of code in a single file as it will give you a “tree-like” interface for your code. This is actually something that won’t be very useful to you right now, but will be in the future. Frankly it would make more sense if this menu option was called “Module Browser” as that is much closer to what you’ll actually be doing. Next there’s a Class Browser that will help you navigate your code. The Path Browser will show you where these files are located on your hard drive, if you have imported anything. You can actually add and remove locations as well. Then it checks a predefined list of other locations. You see, Python first looks in the same directory as the script that is running to see if the file it needs to import is there. In the File menu, you’ll find a Path Browser which is useful for figuring out where Python looks for module imports. For example, you can import the math module for all kinds of good math functions, like square roots, cosines, etcetera. Python comes with lots of modules and packages that you can import to add new features. Now we’ll spend a little time looking at IDLE’s other useful features. The code editor screen looks a little different than the IDLE screenshot above: The primary benefit of using the Python shell is that you can experiment with small snippets to see how your code will behave before you put the code into a real program. Now you can type in your program and save it here. If you want to save your code into a file, go to the File menu and choose New Window (or press CTRL+N). You will learn what functions are in chapter 10. In Python 3, the print statement was turned into a print function, which is why parentheses are required. Type the following after the command prompt (>) in IDLE: There is no compiling of the code as Python is an interpretive language and runs in the Python interpreter. Yes, it’s a Python shell where you can type short scripts and see their output immediately and even interact with code in real time. To open up IDLE, you will need to find it and you’ll see something like this: You might also like to know that IDLE was created using Tkinter, a Python GUI toolkit that comes with Python. The reason I call it “lite” is the debugger is very basic and it’s missing other features that programmers who have a background using products like Visual Studio will miss. It allows the programmer to write Python and debug their code quite easily. IDLE is kind of a lite IDE, but it does have all those items mentioned. You can find an IDE for most popular languages and a number of IDEs will work with multiple languages.

editra command line editra command line

An IDE is an editor for programmers that provides color highlighting of key words in the language, auto-complete, an “experimental” debugger and lots of other fun things. There is some lore that the name for IDLE comes from Eric Idle, an actor in Monty Python. Python comes with its own code editor: IDLE (Integrated Development and Learning Environment).














Editra command line