simple question: $1, $2 in py ?

Lee Harr lee at example.com
Mon Sep 5 18:42:11 CEST 2005


On 2005-09-05, es_uomikim <es_uomikim at ALA_MA_KOTAop.pl> wrote:
> Hi,
>
> I have one small simple question, that I didn't found answer in 
> google's. It's kind of begginers question because I'm a one. ; )
>
> I wanned to ask how to use scripts with vars on input like this:
>
> $ echo "something" | ./my_script.py
>
> or:
>
> $ ./my_scripy.py var1 var2
>
>
> As far as I understand there's no $1, $2... etc stuff right ?
>


Others answered about commandline args... You can also read
from stdin to get the piped input:



# pi.py
import sys
i = sys.stdin.read()
print "Your input: ", i


> echo "something" | python pi.py
Your input:  something







More information about the Python-list mailing list