[python] I just figured this out by accident!

For all coding issues - MODers and programmers, HTML and more.

Moderators: Jeff250, fliptw

Post Reply
User avatar
Isaac
DBB Artist
DBB Artist
Posts: 7137
Joined: Mon Aug 01, 2005 8:47 am

[python] I just figured this out by accident!

Post by Isaac » Sun Jan 20, 2013 11:50 am

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.
:E
User avatar
snoopy
DBB Benefactor
DBB Benefactor
Posts: 4434
Joined: Thu Sep 02, 1999 2:01 am

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

Post by snoopy » Sun Jan 20, 2013 7:47 pm

Yep. You can define default values.
Arch Linux x86-64, Openbox
"We'll just set a new course for that empty region over there, near that blackish, holeish thing. " Zapp Brannigan
Post Reply