Changing the class of an instance

david_ullrich at my-deja.com david_ullrich at my-deja.com
Fri Jul 14 13:15:16 EDT 2000


In article <8kl0c7$1h2n$1 at pc-news.cogsci.ed.ac.uk>,
  richard at cogsci.ed.ac.uk (Richard Tobin) wrote:
> In article <8kkuuv$ohu$1 at nnrp1.deja.com>,  <david_ullrich at my-deja.com>
wrote:
>
> >    If you said what you were trying to do someone would show
> >you how to do it without trying to change the class of an
> >instance.
>
> I can see plenty of other ways to do it myself, thanks.  For example,
> changing the relevant methods of the instance.
>
> >    I can't imagine there being any _argument_ about whether
> >it's a good idea...
>
> It's not as if it's a previously-unheard-of idea I've dreamt up; on
> the contrary it is explicitly provided in some other well-known object
> systems (eg change-class in CLOS).

   It's explicitly provided in Python as well. That doesn't mean
it's a good idea. (I used to really enjoy this sort of
shenanigans, thought the people who advised against it were
just sissies. Then one night I discovered how right they
were...)

   Changing the methods of the instance also counts as
a sneaky don't-do-that. Whatever it is you're trying to
do there's a way to do it in legitimate Python without
this sort of thing. (Or not; with no information on
why you want to do this it's hard to be certain.)

DU

> -- Richard
> --
> Spam filter: to mail me from a .com/.net site, put my surname in the
headers.
>
> "The Internet is really just a series of bottlenecks joined by high
> speed networks." - Sam Wilson
>


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



More information about the Python-list mailing list