Copy constructors
Alex Martelli
aleaxit at yahoo.com
Sat Aug 11 17:58:10 EDT 2001
"Glyph Lefkowitz" <glyph at twistedmatrix.com> wrote in message
news:mailman.997561650.27157.python-list at python.org...
...
> Am I correct in understanding from this thread that there is an intent to
> remove the ability to assign an instance's __class__ attribute?
That's how I'm reading Guido's messages in this thread, too.
> > Let's just say that use of this feature is at your own risk. It was
> > an experiment. I *could* restore it partially (see below) but I'd
> > rather not, given that better alternatives are available.
...
> Also, as far as I know, better alternatives do not exist; for example,
> "promise" objects from a database which are latently initialized when they
> are accessed. One module that I use *all the time*;
I don't know of any better way to handle the Promise design pattern,
either. In C++, I'm having to kludge around it all the time via
letter/envelope idioms -- the possibility of changing classes on
the fly makes it much simpler and more direct. Hadn't thought
of that earlier...
> twisted.python.rebuild.rebuild, is based entirely upon this "trick". One
> of the eye-popping cool features of Python is the ability to change code
> and have existing instances update to use the new methods automatically.
That one seems to be related to _another_ capability (of which I've
seen no indication that it's also going away) -- keeping the same
class object. but changing that object (rebinding method attributes
thereof). Or maybe I don't understand exactly what you mean?
> Smalltalk's Object>>become: is highly useful for similiar reasons; is
> there a new way to emulate this without __class__ assignment?
It seems to me the functionality of become is homomorphic to that
of class-assignment, unless I'm truly missing something major.
Alex
More information about the Python-list
mailing list