[Python-Dev] Semantics of __int__(), __index__()
python-dev at masklinn.net
Thu Apr 4 17:01:25 CEST 2013
On 2013-04-04, at 16:47 , Chris Angelico wrote:
> Sure, I could override __new__ to do stupid things
Or to do perfectly logical and sensible things, such as implementing
"cluster classes" or using the base class as a factory of sorts.
> in terms of logical expectations, I'd expect
> that Foo(x) will return a Foo object, not a Bar object.
The problem is the expectation of what "a Foo object" is: type-wise, any
Bar object is also a Foo object. I would not expect Foo() to return an
object of a completely unrelated type, but returning an object of a
subtype? That does not seem outlandish.
More information about the Python-Dev