Pass A Var To a Python Script?

Michael Bentley michael at jedimindworks.com
Wed Apr 11 07:22:31 EDT 2007


On Apr 7, 2007, at 1:13 PM, Eric Price wrote:

> Hi;
> How do I pass a variable to a python script? Something like this  
> (which
> doesn't work):
>
> ./test.py?var=hello_world

The easiest thing would be to drop the '?var=':

./test.py hello_world

Then in your script, use sys.argv to gather the argument (hello_world).

hth,
Michael





More information about the Python-list mailing list