arguments from the prompt

Fredrik Lundh effbot at telia.com
Tue Feb 8 09:20:14 CET 2000


<joe at localhost.localdomain> wrote:
> >> how do I write a python script to recive arguments from the
> >> command prompt?
> >
> >you import the sys module, and read up on
> >sys.argv in the manual?
>
> it says NameError: sys
>
> from sys import argv

> a=sys.argv[1]

I told you to import the sys module; not import
just argv.  change the first line to "import sys",
and don't forget that you need to explicitly con-
vert strings to numbers before you can do math
on them.

for more info on how import works, see:
http://www.pythonware.com/people/fredrik/fyi/fyi06.htm

</F>





More information about the Python-list mailing list