Warning
This page is located in archive.

FAQ

Problems with DrPython

DrPython does not work well with diacritic. If the file with source code is in folder with diacritic, it does not work. You can change the implicit working folder by creating a shortcut that starts drpython.py with the “ -preferencesbasepath=.” parameter. (Create a shortcut → go to its properties → change the Target field to add the above parameter.)

How to start Python under MS Windows

After installing Python you should have two shortcuts in the Start menu. IDLE (Python GUI) and Python (command line). IDLE is Python IDE, with all the basic features such as colour highlighting syntax and automatic text indentation. Python command line is the usual black shell. IDLE tutorial There are of course many more editors you can use, like DrPython More information about using Python under MS Windows is here.

Python’s Window closes itself right after starting.

Usually, when you run .py script, the Python window closes itself right after finishing. You can solve this by adding raw_input() at the end of the script. Program runs and then waits for user input. By pressing Enter, you close the window. However, if there is an error in the program, it ignores the raw_input() function and closes itself anyway. The proper solution is to set the flag for the so-called “interactive mode”, where the Python runs the program and afterwards waits for your input. You can then close the window with either Ctrl+Z and Enter, or by typing exit(). To do this, you have to run the Python interpreter with “-i” flag. To do this, refer to the MS Windows tutorial.

Python tells me there is an error in my script, how do I find it?

To find errors (bugs), one uses a debugger. Debugger lets you run the code step by step and thus find the bugs. Most editors contain debuggers as well, otherwise you can use the pdb module. In simple cases, we can also just use print statement to write out the variables during runtime, so we can see where it goes wrong. There is also this introduction to the pdb module and this tutorial to debugging techniques

courses/ae4b99rph/tutorials/python/faq.txt · Last modified: 2013/10/04 13:02 (external edit)