15/04/2008

Base class from callable

Sometimes I randomly wonder if something is possible in python the language itself ( and it often is ), this time I wondered if base classes could be callable objects... guess what?...they can!

>>> def b(c):
...     class B(object):
...             d = c
...     return B
...
>>> class A(b(1)):
...     pass
...
>>> A.d
1
>>>

No comments: