Sabtu, 19 Maret 2011

Python Programming on Windows

Windows users who have installed Python, can execute the python file by using python interpreter. This work is somewhat inconvenient, because in addition we need to move from editor to the interpreter many times, we also have to first go into the directory containing python.exe. Using SciTE easier, because in addition to supporting the style of writing with the Python language, we also can execute Python files by using the menu [Tools]> [Go] or by pressing F5 hotkey, much simpler. However, this is not automatic we can do, therefore we need to make some changes.

The steps that we do is as follows:


- From SciTE, open the document Python that you have created previously. If you do not make it, then try using a script that's easy to experiment. For example:
print "Hello World!"
Then save it with the extension *. py or *. pyw.

- Then go to the directory where you installed Python (by default located in b) and copy the files python.exe and pythonw.exe to the directory C: \ Windows.
Until this step you can execute the files that you created earlier from the Output window by using the command:
python-u filename.py (when stored in the extension *. py)
or
pythonw filename.pyw-u (if stored in *. pyw)
To enable the Output window, go to the [View]> [output] or by using the shortcut F8. Some people might still be a little trouble of having to type the above command is repeated every want to execute Python files. So the easier way out is
by using the menu [Tools]> [Go] or with the shortcut F5 to execute. If you do it now, then you will get the message:
> Pythonw-u "filename.py"
> The system can not find the file specified.
If you save it in *. pyw, then the message will get out is:
> Pythonw-u "filename.pyw"
> The system can not find the file specified.

- To solve the above problem, go to the menu
[Options]> [Open python.properties]. Enable Line Number from the [View]> [Line Number]. Then on the line to 64:
command.go .*. py = pythonw-u "$ (FileNameExt)"
change into:
command.go .*. py = python-u $ (FileNameExt)
Then on the line to 66:
.*. command.go pyw = pythonw-u "$ (FileNameExt)"
change into:
command.go .*. py = pythonw-u $ (FileNameExt)
Save your work and now try to use the menu [Tools]> [Go] or F5.
You are not going to get the error message again.
- From this python.properties you still can do the other settings, such as changing sintax styling, like the color and model letters, according to your taste.

Related Post :



0 comments:

R