> No, it's nothing special about groupby. record simply stores its
state in a
> mutable default parameter. This isn't general good practice: at
least you have
> to be careful with it. You can see the behavior in the following
> >>> def accumulate(value, accum = ):> ... accum.append(value)> ... return accum> ...> >>> accumulate(1)> > >>> accumulate(2)> [1, 2]> >>> accumulate(6)> [1, 2, 6]> >>>
Wow.... I'd never seen this kind of thing in examples of Python code.
Although its really neat, it doesn't really make sense, intuituvely to
me. Why does accum remember its state - I suppose its to do with the
scope of arguments (as opposed to method variables) or something like
Still, thats powerful. But I see why its not standard use - it could
be easily abused!