How to save python codes in files?

Evan Klitzke evan at yelp.com
Wed Jun 13 01:08:52 EDT 2007


On 6/12/07, why? <jimbomaan at gmail.com> wrote:
> Im working with Python 2.2 on my red hat linux system. Is there any
> way to write python codes in separate files and save them so that i
> can view/edit them in the future? Actually I've just started with
> python and would be grateful for a response. Thanx!

Of course -- just put the code into a text file (using your favorite
text editor) and then run the script using the python command, e.g. by
executing on a command line:
  python my_program.py

Since you're on a Linux system you can also use this as the first line
of your file and then chmod +x the file to make it into an executable
script:

#!/usr/bin/env python

-- 
Evan Klitzke <evan at yelp.com>



More information about the Python-list mailing list