How to create an object "Two"? Neither constr () nor c () work; and it seems that the application turns it into a type.
The above comment was made regarding this code:
>>> def digest(constr):
... c = apply(constr)
... print c.__class__.__name__
... print constr.__class__.__name__
apply(deprecated: see @pyfunc answer), of course, does not turn a class Twointo a type: it is already one.
>>> class Two(object): pass
...
>>> type(Two)
<type 'type'>
- : type. , .
>>> two = Two()
>>> type(two)
<class '__main__.Two'>
, , type. .
>>> Three = type('Three', (Two, ), {'foo': 'bar'})
>>> type(Three)
<type 'type'>
>>> three = Three()
>>> type(three)
<class '__main__.Three'>
, type - , . : , , . type aka.
,
, ?
. - type, . , , , , , : .