Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Meta(type):
- def mro(self):
- print("! Computing MRO")
- return super().mro()
- class Foo:
- x = 'foo'
- class Bar:
- x = 'bar'
- print("Defining Baz")
- class Baz(Foo, metaclass=Meta):
- pass
- print("Instantiating Baz")
- b = Baz()
- print("Accessing attribute")
- b.x
- print("Changing Baz's bases")
- Baz.__bases__ = (Bar,)
- print("Accessing attribute")
- b.x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement