I have a function with optional arguments x, y and I would like to pass y or z using a named variable through the command line. Inside a python script main(y=3) would work, but I have trouble passing y=3 as an argument in command line.
I have tried the following: ---- import sys def main(x=1, y=2): print x print y if __name__ == '__main__': main(*sys.argv[1:]) ----- from my terminal I get: $ python script.py 1 2 $ python script.py y=3 y=3 2 whereas I would like the following to happen: $ python script.py y=3 1 3 Is this doable in any convenient way? thanks in advance! -Robert
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor