G
Geoff Bache
Hi,
I'm wondering if there is any way to customize class attribute access
on classic classes?
So this works:
class Meta(type):
def __getattr__(cls, name):
return "Customized " + name
class A:
__metaclass__ = Meta
print A.blah
but it turns A into a new-style class.
If "Meta" does not inherit from type, the customization works but A
ends up not being a class at all, severely restricting its usefulness.
I then hoped I could get "Meta" to inherit from types.ClassType but
that wasn't allowed either.
Is there any way to do this or is it just a limitation of classic
classes?
Regards,
Geoff Bache
I'm wondering if there is any way to customize class attribute access
on classic classes?
So this works:
class Meta(type):
def __getattr__(cls, name):
return "Customized " + name
class A:
__metaclass__ = Meta
print A.blah
but it turns A into a new-style class.
If "Meta" does not inherit from type, the customization works but A
ends up not being a class at all, severely restricting its usefulness.
I then hoped I could get "Meta" to inherit from types.ClassType but
that wasn't allowed either.
Is there any way to do this or is it just a limitation of classic
classes?
Regards,
Geoff Bache