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:
Post a Comment