newbie question...

Tim Chase python.list at
Fri Dec 12 18:58:32 CET 2008

> Im new at python and I just want to know if (and how) it is possible
> to send parameters to a program.
> what I mean is that when we start python I can call a file that should
> be run like this: python
> can I send additional parameters along with it?  like::: python
> myVar1 myVar2

You're looking for sys.argv:

  tim at rubbish:~$ python - one two
  Python 2.5.2 (r252:60911, May 28 2008, 08:35:32)
[GCC 4.2.4 (Debian 4.2.4-1)] on linux2
Type "help", "copyright", "credits" or "license" for more 
  >>> import sys
  >>> sys.argv
  ['-', 'one', 'two']


More information about the Python-list mailing list