Question about instance creation
Robin Barendregt
r.barendregt at village.uunet.be
Mon Mar 20 18:49:30 EST 2000
Joshua Macy <amused at webamused.com> wrote:
> I think the question is "Why do you want to do this?" You can maybe
>get the behavior that you're looking for by messing with the __bases__
>attribute of the object's __class__ on the fly, but that sort of thing
>is fraught with difficulties. You're talking about violating some of
>the fairly basic ideas of the object-oriented paradigm (such as the
>object's type won't change over the lifetime of the object); if you
>could describe the problem that you're trying to solve by doing this,
>maybe someone could suggest a more straightforward Pythonic approach to
>solving the same problem.
>
> Joshua
My problem is as follows:
I'm fooling around with wxPython and want to instantiate objects
(wxButton, wxFileDialog, etc....) and drop them on a canvas...kinda
like a visual programming editor. With every object I associate a
rectangular shape (to make it easier to show when the objects are
selected and when connections between objects are made). There are a
gazillion different classes of those objects and didn't want to
subclass them all. That's why I wanted a derived class with changing
base class.
Robin.
More information about the Python-list
mailing list