In Python it is possible to create new type object without any name (or more precisely with an empty name).
Moreover, you can create an anonymous (empty) class variable.
For example to create Phantom class with anonymous (empty) class variable:
Moreover, you can create an anonymous (empty) class variable.
For example to create Phantom class with anonymous (empty) class variable:
>>> Phantom = type('', (object,), {'': 'surprise'}) >>> p = Phantom() >>> Phantom.__name__ '' >>> p.__class__ <class '__main__.'> >>> getattr(p, '') 'surprise'
No comments:
Post a Comment