On Mon, Mar 28, 2011 at 1:24 PM, Susana Iraiis Delgado Rodriguez <
susana.delgad...@utzmg.edu.mx> wrote:

> Hello everyone!
>
> I want to run a python script which reads arguments from command line. I
> searched in web and the module sys.argv came up. But I don't understand how
> it works. I need to know how to pass arguments from command line and make
> the python script works from MS-DOS instead of run my program from the
> python console.
>
> Is there any documentation?
>
>
if you have the following command:
python myprogram.py first second third

sys.argv[0] will be "myprogram.py"
sys.argv[1] will be "first"
sys.argv[2] will be "second"

and so forth

If you need more complicated command line parsing you should look into
argparse


_______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Joel Goldstick
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to