News for hackers. Stuff that matters.
Re:Python's Mutable Default Problem by neutronicus on Sunday February 20, 2011 @11:37AM (#2242249)
"stuff = stuff or []"

This idiom is baked into the perl community. It's kind of funny to see a Pythonista deciding it's a good idea. (You can tell it hurts him too).

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.
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).
Re:Python's Mutable Default Problem by dagw on Sunday February 20, 2011 @02:16PM (#2242710)
I've been programming python for on and off 12 years, and full time for the past 3, and this is the first time I've seen anyone recommending that idiom. So on the whole the python community does not think it's a good idea.
Re:Python's Mutable Default Problem by code_duck on Sunday February 20, 2011 @03:21PM (#2242909)
JavaScript, too:

    stuff = stuff||[]
since JavaScript doesn't even support default argument values.