Python meta object question

Mickael Remond mikl at
Mon Nov 29 20:12:37 CET 1999


Is there a way to automatically update the class tree to show the change
in inherited class attributes after a class redefinition ?

Look at this example:

# Step one
# First description
class company1:
    company = "Company1"

class company2:
    company = "Company2"

class localcompany(company1):
    localcompany = "STE France"

class employee(localcompany):
    employee = "Me"

print "Step 1:"
print         # => Company1
print             # => Company1

# Step two
# localcompany is sold to company2
class localcompany(company2):
    localcompany="New STE France"

print "Step 2:"
print         # => Company2
print             # => Company1 (outdated!)

# Step three
# Force employee class update (same class definition)
class employee(localcompany):
    employee = "Me"

print "Step 3:"
print         # => Company2
print             # => Company2

This case is very simple but when the class tree becomes complicated it
is difficult to keep all class up to date.

Is there a way to redefined only one class, as in step 2 and have all
the other class automatically take this change into account ?

Thank you in advance for your help.

Mickael Remond

More information about the Python-list mailing list