lo there all,

i was wondering how to make a python script accept command line arguments.
i mean, i have used python scripts from the command line in linux and
passed something to it and it knows what to do.

like in a function, if i want to do something like this

def add_two_numbers(a, b):
    x = a + b
    return x

x = add_two_numbers(4,5)
print x

how could i do the same from the cli.

like python add_two_numbers.py 4 5
or maybe python add_two_numbers.py 4, 5
or even python add_two_numbers.py -a 4 -b 5

is there an easy way to do this ?

thanks
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to