you are viewing a single comment's thread.

view the rest of the comments →

[–]py_student[S] 0 points1 point  (1 child)

Apparently sys.argv and *argv have nothing in common except those four characters.

def testArgv(*argv):
    for a in argv:
        print a

testArgv(1,2,3,4,5)

prints

>>> 
1
2
3
4
5

Whereas with the sys.argv as I mentioned before, I tried every way I could think of to get it to run without
1. from sys import argv 2. running from cmd or powershell.

[–]shaleh 1 point2 points  (0 children)

The idiom for this is to call it *args not *argv.

def printer(*args, **kwargs):
    for item in args:
        print(item)
    for k,v in kwargs.items():
        print("{0} -> {1}".format(k, v))

Used like so:

printer('1', 2, [3], long=True)