[Tutor] run time parameters
D-Man
dsh8290@rit.edu
Mon, 26 Feb 2001 16:36:40 -0500
On Mon, Feb 26, 2001 at 01:30:58PM -0800, Cris Paltenghe wrote:
|
| For the life of me, I can't figure out how to pass the file name (or a
| directory) as a run time parameter.
| I have found directory functions, but I would like to know how generally to
| pass parameters to a program.
|
| Also, where should I have gone to figure this out?
| I have been pouring over all the docs I could find.
sys.argv is the same as argv , len( sys.argv ) is the same as argc in
C :
int main( int argc , char** argv ) { ... }
~~~~~~~~~~~ Test.py ~~~~~~~~~~~~~~
#!/usr/bin/env python
import sys
print sys.argv
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ ./Test.py arg1 some_file a_directory
['Test.py', 'arg1', 'some_file', 'a_directory']
HTH,
-D