Re:Python's Mutable Default Problem
by jacobolus on Sunday February 20, 2011 @12:00PM
(#2242306)
It’s not a good idea in Python. There are legitimate reasons to pass falsy objects as function arguments.
[ Parent
| on HN ]
Re:Python's Mutable Default Problem
by robinhouston on Sunday February 20, 2011 @01:46PM
(#2242645)
Funnily enough, Perl (since version 5.10) actually has a solution to this. The expression
$foo // "default"
evaluates to "default" if $foo is undefined, and to $foo otherwise (even if it is defined but false).