How to create and save python program files?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • koolest1
    New Member
    • Jun 2007
    • 7

    #1

    How to create and save python program files?

    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!
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by koolest1
    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!
    I'm not a *nix guy, but I understand that any text file with the first line to the effect of
    Code:
    #!/usr/bin/env python
    should do it.

    Comment

    • Smygis
      New Member
      • Jun 2007
      • 126

      #3
      like this:

      [code=python]
      smygis@Bob:~$ nano myscript.py
      smygis@Bob:~$ cat myscript.py
      #!/usr/bin/env python
      # coding: UTF-8

      print "Hej världen. (Hello world in swedish)"
      smygis@Bob:~$
      smygis@Bob:~$ chmod +x myscript.py
      smygis@Bob:~$ ./myscript.py
      Hej världen. (Hello world in swedish)
      smygis@Bob:~$
      smygis@Bob:~$ nano myscript.py
      smygis@Bob:~$ cat myscript.py
      #!/usr/bin/env python
      # coding: UTF-8

      print "Hej världen. (Hello world in swedish)"
      print "Added one line."
      smygis@Bob:~$
      smygis@Bob:~$ ./myscript.py
      Hej världen. (Hello world in swedish)
      Added one line.
      smygis@Bob:~$
      [/code]

      For those who dont know, nano is a CLI texteditor.

      Comment

      Working...