On 04/04/13 01:16, Barry Warsaw wrote:
On Apr 03, 2013, at 09:17 PM, Nick Coghlan wrote:
Perhaps we should start emitting a DeprecationWarning for int subclasses
returned from __int__ and __index__ in 3.4?
I definitely agree with doing this for __int__(), since it's intimately tied
to int(), which is clearly a type conversion operation. It's analogous to all
the other built-in types-as-functions, so int() calls __int__() which must
return a concrete integer.
Why must it? I think that's the claim which must be justified, not just taken
as a given.
When we call n = int(something), what's the use-case for caring that n is an
instance of built-in int but not of a subclass, and is that use-case so
compelling that it must be enforced for all uses of int() etc.?
As I see it, what I expect is this:
n = int(something)
assert isinstance(n, int)
not this:
n = int(something)
assert type(n) is int
I haven't cared about checking type identity since "Unifying types and classes"
way back in Python 2.2, and I don't see why we should enforce a more restrictive rule now.
--
Steven
_______________________________________________
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