A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-April/125110.html below:

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

[Python-Dev] Semantics of __int__(), __index__()Chris Angelico rosuav at gmail.com
Thu Apr 4 17:01:53 CEST 2013
On Fri, Apr 5, 2013 at 1:59 AM, Guido van Rossum <guido at python.org> wrote:
> On Thu, Apr 4, 2013 at 7:47 AM, Chris Angelico <rosuav at gmail.com> wrote:
>> 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. Why should int
>> be any different? What have I missed here?
>
>
> A class can define a __new__ method that returns a different object. E.g.
> (python 3):
>

Right, I'm aware it's possible. But who would expect it of a class?

ChrisA
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4