How to save python codes in files?

markacy markacy at gmail.com
Wed Jun 13 10:21:53 CEST 2007


On 13 Cze, 10:06, why? <jimbom... at gmail.com> wrote:
> Evan Klitzke wrote:
> > On 6/12/07, why? <jimbom... 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
>
> > --
>
> Im still unable to follow... :(
> See, if i have to save the following code in a file, how should i
> proceed?
>
> >>> def sum(x,y): return x+y
> ...

:D You should try some basic manual on linux :D

Copy and paste the code (do not include >>> and ...) to the editor,
save. Then run as advised above.
Good luck.

Cheers,
Marek




More information about the Python-list mailing list