command line argument passing

Dennis Benzinger Dennis.Benzinger at gmx.net
Fri Jul 22 15:19:19 CEST 2005


Hayri ERDENER schrieb:
> hi to all,
> is it possible in python to pass arguments by using command prompt in
> windows 2000 and XP ?
> for example:
> sourceCode.py  factorial  4
>  gives me the factorial of 4 namely 24. 
> best regards

import sys

print sys.argv


Or use the optparse module. Docs:
http://www.python.org/doc/2.4.1/lib/module-optparse.html

Bye,
Dennis



More information about the Python-list mailing list