By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,203 Members | 1,633 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,203 IT Pros & Developers. It's quick & easy.

How to create and save python program files?

P: 7
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!
Jun 12 '07 #1
Share this Question
Share on Google+
2 Replies


bartonc
Expert 5K+
P: 6,596
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
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/env python
should do it.
Jun 12 '07 #2

Smygis
100+
P: 126
like this:

Expand|Select|Wrap|Line Numbers
  1. smygis@Bob:~$ nano myscript.py
  2. smygis@Bob:~$ cat myscript.py 
  3. #!/usr/bin/env python
  4. # coding: UTF-8
  5.  
  6. print "Hej världen. (Hello world in swedish)"
  7. smygis@Bob:~$ 
  8. smygis@Bob:~$ chmod +x myscript.py 
  9. smygis@Bob:~$ ./myscript.py 
  10. Hej världen. (Hello world in swedish)
  11. smygis@Bob:~$ 
  12. smygis@Bob:~$ nano myscript.py 
  13. smygis@Bob:~$ cat myscript.py 
  14. #!/usr/bin/env python
  15. # coding: UTF-8
  16.  
  17. print "Hej världen. (Hello world in swedish)"
  18. print "Added one line."
  19. smygis@Bob:~$ 
  20. smygis@Bob:~$ ./myscript.py 
  21. Hej världen. (Hello world in swedish)
  22. Added one line.
  23. smygis@Bob:~$ 
  24.  
For those who dont know, nano is a CLI texteditor.
Jun 12 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.