How to "cast" an object to a derived class?

Robert Latest boblatest at yahoo.com
Sat Sep 18 09:03:54 EDT 2021


Stefan Ram wrote:
> Robert Latest <boblatest at 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.



More information about the Python-list mailing list