initializing mutable class attributes

Dan Perl dperl at rogers.com
Thu Sep 2 16:04:33 CEST 2004


"Alex Martelli" <aleaxit at yahoo.com> wrote in message
news:1gjhleb.6l5nbvaf0x06N%aleaxit at yahoo.com...
> Bengt Richter <bokr at oz.net> wrote:
>    ...
> I could use it in the Cookbook, side by side with Dan's "overloading
> __new__" idea and my custom metaclass, as various approaches to solving
> a 'problem' (if that be one) of "automatically initializing mutable
> instance attributes".  It would help if you and/or Dan posted these
> recipes to ActiveState's online cookbook ASAP (deadline is Sat Sep 5...)
> -- I'm allowed to add recipes that didn't show up on the online
> cookbook, but that _is_ discouraged... (and posting the recipes myself
> isn't much better, either).

I already submitted mine.  It's recipe #303059, so go to:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303059

You are right in an earlier posting that another call to __init__ in the
__new__ was redundant.  It was even a problem when using it in the multiple
inheritance case.  I figured out eventually that it's not needed and I got
rid of it.

Dan





More information about the Python-list mailing list