Page 1 of 1

[python] I just figured this out by accident!

Posted: Sun Jan 20, 2013 11:50 am
by Isaac
So this is regular use:

Code: Select all

>>> def a(x=0,y=0,z=0):
...     print x
...     print y
...     print z
... 
>>> a(3,2,4)
3
2
4
>>> a()
0
0
0
Now, for the amazing part:

Code: Select all

>>> a(z=3)
0
0
3
YEAHHH!!!!!!

This has just saved me lots of time, for a complicated messy method I'm calling.

Re: [python] I just figured this out by accident!

Posted: Sun Jan 20, 2013 7:47 pm
by snoopy
Yep. You can define default values.