[Python-Dev] Semantics of __int__(), __index__()

Antoine Pitrou solipsis at pitrou.net
Thu Apr 4 17:19:10 CEST 2013


Le Fri, 5 Apr 2013 01:47:45 +1100,
Chris Angelico <rosuav at gmail.com> a écrit :
> 
> class Foo:
>     pass
> 
> class Bar(Foo):
>     pass
> 
> Is there any argument that I can pass to Foo() to get back a Bar()?
> Would anyone expect there to be one? Sure, I could override __new__ to
> do stupid things, but in terms of logical expectations, I'd expect
> that Foo(x) will return a Foo object, not a Bar object.


>>> OSError(errno.ENOENT, "couldn't find that file")
FileNotFoundError(2, "couldn't find that file")

Regards

Antoine.




More information about the Python-Dev mailing list