using module sys one can get command line arguments like this
import sys
for x in sys.argv:
print x
then at command shell[ubunto]
>>python file.py 1, 2, 3
this will print
file[filename]
1
2
3
Now comes my doubt
in python documentaion 3.0.1 it is mentioned that
If no script name was passed to the Python interpreter, argv[0] is the empty string.
>>python 1, 2, 3
if i pass no script name , it will lead to error that ‘can’t open a file’. How would argv[0] be intitialized to an empty string when you are not passing script name ?
In the shell, you can do something like
python -c "print 'Hello World!'", or you can put source code into python through a pipe. In such cases, no filename is available for python. In all other cases, Python will have a filename. Even if you use a shebang-line:and then call
the shell will translate it to the correct interpreter call