On 4/3/2013 3:36 PM, Ethan Furman wrote:
On 04/03/2013 12:21 PM, Tres Seaver wrote:
Given that requirement, we still don't have to mandate that __int__
return an actual instance of the int type: the coercion could happen
inside int() (as it would for any non-subclass).
I don't understand. A non-int could only become an int via __int__,
which int() calls. What magic is there in int() to turn any arbitrary
object into an integer?
From the 2.7 manual:
"
object.__complex__(self)
object.__int__(self)
object.__long__(self)
object.__float__(self)
Called to implement the built-in functions complex(), int(), long(), and
float(). Should return a value of the appropriate type."
I have always understood 'value of the appropriate type' to mean just
what Guido says he intended it to mean. Changing to 'instance of the
class or subclass thereof' is a change.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com