[Tutor] Inheriting from parent object

Ed Singleton singletoned at gmail.com
Mon Nov 14 13:19:00 CET 2005


I want to create a property that will inherit it's value from the same
property in it's parent object, but will check it's parent's propety
everytime it is called.  But that can be over-ridden, and I don't have
to know what the objects parent is.

For example:

object.x = 3
object.subobject.x = inherit()
print object.subobject.x #prints 3
object.x = 4
print object.subobject.x #prints 4
object.subobject.x = 5
print object.subobject.x #prints 5

What could I put in the inherit() function that would look for the
same property of it's parent and return that, whilst keeping it as
general as possible?

Thanks

Ed


More information about the Tutor mailing list