Python instances

Kent Johnson kent37 at tds.net
Thu Apr 21 07:58:14 EDT 2005


Bengt Richter wrote:
> The following shows nothing static anywhere, yet a class has been defined, an instance created, and
> __init__ called with initial value, and the value retrieved as an attribute of the returned instance,
> and it's all an expression.
> 
>  >>> type('C', (), {'__init__': lambda self,v:setattr(self,'foo',v)})('hello').foo
>  'hello'

I have no idea what point you are trying to make, except maybe that it is possible to obfuscate a 
simple class definition.

Kenw



More information about the Python-list mailing list