Changing the class of an instance

david_ullrich at my-deja.com david_ullrich at my-deja.com
Tue Jul 18 11:12:37 EDT 2000


In article <3bRLJW$k02 at openbazaar.net>,
  cut_me_out at hotmail.com.bbs@openbazaar.net (Alex) wrote:
> >     I don't think "confusing" is the right word. Although I'm fairly
> > certain I won't get the words right: It destroys the...  maybe the
> > word is "encapsulation" or "modularity" or something - it means that
> > you cannot verify things are correct by just looking at things
> > locally.
>
> You're probably right, I don't know much of the jargon.
>
> > Not sure what sort of debugging we're referring to. If you're trying
> > to figure out how to do something, as opposed to writing code meant
to
> > be used later, that's different.
>
> True, that's what I was trying to do, so the changing of the class was
> only happening on a very limited and interactive level (and it still
got
> a bit confusing at times. :)
>
> > Possibly I missed it, but I haven't seen any reason given why
changing
> > __class__ is better than creating a new instance
>
> Well, if you want to do it by creating a new instance, you have to
make
> some sort of copy constructor.  Unless you automate the process so
that
> it copies every attribute of the instance, you are bound to forget one
> at some point.

   _If_ we're talking about real code meant to be actually used,
as opposed to temporary experimental code, then the code is
presumably tested at some point - the NameError should be
a hint that something's missing...

> Alex.
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list