[Tutor] sys.argv?

Scott Comboni scott@zenplex.com
Mon, 27 Nov 2000 13:01:25 -0500


On Monday 27 November 2000 12:22, you wrote:
> > test(sys.argv[1], sys.argv[2])
> >
> > ./test.py Foo 3
> >
> > my problem is when I'm using sys.argv to pass in a number it
> > converts to a string.
>
> No it doesn't, argv is a list of strings...
>
> > Is there a way around this using sys.argv or do I
> > have to use string.atoi(n) to convert it back to int?
>
> test(sys.argv[1],int(sys.argv[2]))
>
> could be used, but you should wrap in try/except in
> case its not compatible and of course check that there
> are at least 2 arguments present!
>
> Alan G.
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor

Thanks everyone.... Using the method Alan suggested saves me a step. 
Should have tried that before submitting to the group...
Scott