Passing Arguments

Tim Chase python.list at tim.thechases.com
Fri Sep 29 14:23:39 EDT 2006


> It works fine when I 'Run Module'...but when I type in interactive mode
> in the Python Shell
>>>> python using_sys.py test1 test2 test3
> 
> I get the following error:
> SyntaxError: invalid syntax


By using proper syntax... :*)

To pass parameters, you do it when *starting* python[*].  Thus, 
you'd use something like

c:\test\> python -i using_sys.py test1 test2 test3

or

tim at oblique:~/tmp> python -i using_sys.py test1 test2 test3

from your *system* command-prompt/shell (not the python shell) 
which will (with the "-i" parameter) leave you in the *python* 
command interpreter/shell.

-tkc


[*]  yes, you can write to the sys.argv to make them what you 
want for testing purposes, but that's intentionally and 
purposefully prevaricating about the meaning of "argv".  Best 
left for when it's what you really mean to do.







More information about the Python-list mailing list