![](https://csdnimg.cn/release/download_crawler_static/9742022/bg12.jpg)
1 one of the leading Perl6/Parrot hackers and the author of the amazing 'Beginning Perl' book
One of the very basic requirements is syntax highlighting where all the different parts of your Python
program are colorized so that you can see your program and visualize its running.
If you are using Windows, then I suggest that you use IDLE. IDLE does syntax highlighting and a lot
more such as allowing you to run your programs within IDLE among other things. A special note: don't
use Notepad - it is a bad choice because it does not do syntax highlighting and also importantly it does
not support indentation of the text which is very important in our case as we will see later. Good editors
such as IDLE (and also VIM) will automatically help you do this.
If you are using Linux/FreeBSD, then you have a lot of choices for an editor. If you are an experienced
programmer, then you must be already using VIM or Emacs. Needless to say, these are two of the most
powerful editors and you will be benefitted by using them to write your Python programs. I personally
use VIM for most of my programs. If you are a beginner programmer, then you can use Kate which is
one of my favorites. In case you are willing to take the time to learn VIM or Emacs, then I highly re-
commend that you do learn to use either of them as it will be very useful for you in the long run.
If you still want to explore other choices of an editor, see the comprehensive list of Python editors
[http://www.python.org/cgi-bin/moinmoin/PythonEditors] and make your choice. You can also choose
an IDE (Integrated Development Environment) for Python. See the comprehensive list of IDEs that sup-
port Python [http://www.python.org/cgi-bin/moinmoin/IntegratedDevelopmentEnvironments] for more
details. Once you start writing large Python programs, IDEs can be very useful indeed.
I repeat once again, please choose a proper editor - it can make writing Python programs more fun and
easy.
Using a Source File
Now let's get back to programming. There is a tradition that whenever you learn a new programming
language, the first program that you write and run is the 'Hello World' program - all it does is just say
'Hello World' when you run it. As Simon Cozens 1 puts it, it is the 'traditional incantation to the pro-
gramming gods to help you learn the language better' :) .
Start your choice of editor, enter the following program and save it as helloworld.py
Example 3.2. Using a Source File
#!/usr/bin/python
# Filename : helloworld.py
print 'Hello World'
(Source file: code/helloworld.py)
Run this program by opening a shell (Linux terminal or DOS prompt) and entering the command py-
thon helloworld.py. If you are using IDLE, use the menu Edit -> Run Script or the keyboard short-
cut Ctrl-F5. The output is as shown below.
Output
First Steps
7
www.linuxidc.com
Linux公社(LinuxIDC.com) 是包括Ubuntu,Fedora,SUSE技术,最新IT资讯等Linux专业类网站。