S
Steven Bethard
Felix said:> [snip]
>
> I'm just seeing that the web page says:
>
> | If you return an existing object, the constructor call will still
> | call its __init__ method. If you return an object of a different
> | class, its __init__ method will be called.
>
> However, the latter doesn't seem to be true, or am I missing
> something?
> > ... def __init__(self):
> ... print 'Init of A.'
> ...
> > Init of A.
> > ... def __new__(self):
> ... return instance
> ... def __init__(self):
> ... print 'Init of B.'
> ...
> > Init of B.
> <__main__.B object at 0x406243ec>
>
> So there seems to be some type-checking in type.__call__.
Yeah, I saw the same thing in playing around with this. Don't know what
to make of it. I wonder if we should file a documentation bug? I can't
find __new__ explained anywhere in the Language Reference. Can
documentation bugs be filed for descrintro.html?
STeVe