Re: [Tutor] Read arguments from command line

2011-03-28 Thread Joel Goldstick
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


Re: [Tutor] Read arguments from command line

2011-03-28 Thread Blockheads Oi Oi

On 28/03/2011 18:24, Susana Iraiis Delgado Rodriguez 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?



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
See this from a well known Python tutorial 
http://www.faqs.org/docs/diveintopython/kgp_commandline.html


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


[Tutor] Read arguments from command line

2011-03-28 Thread Susana Iraiis Delgado Rodriguez
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?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor