Robert Latest wrote at 2021-9-18 13:03 GMT: >Stefan Ram wrote: >> Robert Latest <boblat...@yahoo.com> writes: But how can I "promote" a >>>given Opaque instance to the derived class? >> >> Sometimes, one can use containment instead of inheritance. > >Nah, doesn't work in my case. I'm trying to write a wrapper around >xml.etree.ElemenTree and .Element to circumvent its idiotic namespace >handling. For that I need inheritance since I want to override the find..() >functions to return my derived MyElement classes. I think it could work but I >somehow need to convert the root Element to a MyElement.
If the class is a pure Python class, then the `__class__` attribute of its instances is writable. You could try to assign the derived class -- at your own risk. -- Dieter -- https://mail.python.org/mailman/listinfo/python-list