[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: 7649
Joined: Mon Aug 01, 2005 8:47 am
Location: 🍕

[python] I just figured this out by accident!

Post 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.
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-★ ·:*¨༺꧁༺ :E ༻꧂༻¨*:·.★-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
User avatar
snoopy
DBB Benefactor
DBB Benefactor
Posts: 4435
Joined: Thu Sep 02, 1999 2:01 am

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

Post by snoopy »

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