Class mutation
Dale Strickland-Clark
dale at riverhall.NOSPAMco.uk
Thu Sep 27 08:11:32 EDT 2001
More information about the Python-list mailing list
Thu Sep 27 08:11:32 EDT 2001
- Previous message (by thread): Class mutation
- Next message (by thread): Class mutation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Thomas Heller" <thomas.heller at ion-tof.com> wrote: >"Dale Strickland-Clark" <dale at riverhall.NOSPAMco.uk> wrote in message news:8626rt838oe59d1njrtrisccm0oe02shvf at 4ax.com... >> Lets say we have a class 'Job' and another class derived from that >> 'ActiveJob'. >> >> I'd like to mutate a Job object into the extended ActiveJob object >> without re-assigning all the attributes. >> >class Job: > def work(self): > print "I'm inactive" > >class ActiveJob(Job): > def work(self): > print "Ok, later" > >job = Job() > >print job >job.work() > >job.__class__ = ActiveJob > >print job >job.work() > >prints: > ><__main__.Job instance at 007B5EBC> >I'm inactive > ><__main__.ActiveJob instance at 007B5EBC> >Ok, later > >Thomas > Interesting but looks doomed (See other comment.). Thanks -- Dale Strickland-Clark Riverhall Systems Ltd
- Previous message (by thread): Class mutation
- Next message (by thread): Class mutation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list