On Aug 11, 2010, at 8:47 PM, Bradley Hintze wrote:
Hi all,
Is there a way that I can startup my script and pass it a file? For
example:
~$ python myscript.py mytext.txt
and then access mytext.txt in myscript.py?
Option 1: use stdin
~$ python myscript.py < mytext.txt
>>> import sys
>>> file = sys.stdin
Option 2: read command line arguments
>>> import sys
>>> file = open(sys.argv[1])
Cheers, Roald
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.