Changing class membership
Lee, Rick
rickylee at americasm01.nt.com
Wed Sep 27 15:47:35 EDT 2000
I have a similar design problem and was thinking about changing a class
instance's __class__ attribute momentarily (ie., in one thread of that
instance's execution), and then changing it back.
What are its gotcha's?
Obvious ones:
- the new instance class's method may be referring to an object name that
is not in the original instance's name space.
Rick Lee
Alex wrote:
> > How do i most elegantly let an object switch its class membership?
>
> The class is specified by the __class__ attribute. Use it carefully --
> doing this a lot can make things really confusing.
>
> Alex.
>
> --
> Speak softly but carry a big carrot.
More information about the Python-list
mailing list