Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
instance and class-hierarchy ?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Bror Johansson, post: 1872177"] Hi, I have a class-hierarchy (fairly deep and fairly wide). Is there a good and general way to test an instance-object obj for having a class belonging to a certain "sub-tree" of the hierarchy with a common parent class C? Testing for presence of attributes created at __init__ time is not considered general. Testing presence in the set of (manually enumerated) classes belonging to the "subtree" is not considered general. Testing like this: if C in [obj.__class__] + list_of_superclasses_to(obj.__class__): ... is general but I'm looking for a better way, if there is one. /BJ [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
instance and class-hierarchy ?
Top