Re:Python's Mutable Default Problem
by crystalis on Sunday February 20, 2011 @01:34PM
(#2242617)
That hides default logic in the signature. Why would you favor that over
[ Parent
| on HN ]
That is code is logically convoluted — that's one reason not to love it. Why do you think is the more straightforward statement, just in general?
- "Let B be one greater than A unless otherwise specified."
- "We have no default value for B. If B has a value, then let B be equal to that value. If B does not have a value, then let B be one greater than A."
Because that can be said more succinctly. It is even easier to read as there is less to read, which I realize is mostly subjective.
I'm pretty sure this is the same argument used to make Perl a bad guy.
I disagree, but we've gotten a bit off topic.
I think Python's behaviour is confusing and basically never what anyone actually wants. Regardless of whether or not you can use other params in defaults, the defaults should be evaluated on each call.