In the following example we will write a variation of the mandatory “Hello World” script:
>>> print "It's easy to write a Python script!" It's easy to write a Python script! >>>
The interactive interpreter is great for checking small bits of code, but if we have to write a serious program or script, we need to save our script in a file.
Let’s save our mini program in a source file. To save and edit programs in a file we need an editor. There are lots of editors, but you should choose one, which supports syntax highlighting and indentation. Under Linux you can use vi, vim, emacs, geany, gedit and umpteen others.
So, after you have chosen your editor, you can input your mini script and save it as easy_to_write.py.
The suffix .py is not really necessary under Linux but it’s good style to use it. But it is essential, if you want to write modules. Continue reading Execute a Python script