Copy constructors

Moshe Zadka m at moshez.org
Sun Aug 12 07:51:20 CEST 2001


On Sat, 11 Aug 2001 11:37:36 +0200, "Alex Martelli" <aleaxit at yahoo.com> wrote:

> I call the feature 'rarely used', but others may use it less
> rarely.  Moshe Zadka, for example, has advocated that a
> class-change is the right way to 'customize' a specific
> instance, rather than adding a method to the instance itself
> on the fly (I'm not quite sure why, and wouldn't want to
> misrepresent his position, but I believe it has to do with a
> wish to see behavior as associated with _classes_, not with
> _instances_).

So let me reiterate my arguments: you avoid a reference loop (since
the binding is done lazily as usual), and you have better debuggability,
since you can *see* this instance is "different". More, in the usual
case where this is done wholesale for a bunch of instances, then it is
much cleaner.

FWIW, assignment to __class__, while as esoteric trick, is one of the
features I love most in Python and I would absolutely hate to lose it. 
-- 
Moshe Zadka - http://moshez.geek
(if you're not cool, http://moshez.org is still working)




More information about the Python-list mailing list