[Python-Dev] Semantics of int(), index() (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Wed Apr 3 13:17:06 CEST 2013
- Previous message: [Python-Dev] Semantics of __int__(), __index__()
- Next message: [Python-Dev] Semantics of __int__(), __index__()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2 Apr 2013 19:04, "Antoine Pitrou" <solipsis at pitrou.net> wrote:
Le Tue, 2 Apr 2013 09:53:41 +0100, Mark Dickinson <dickinsm at gmail.com> a écrit : > On Tue, Apr 2, 2013 at 9:33 AM, Mark Shannon <mark at hotpy.org> wrote: > > > > > Hence my original question: what should the semantics be? > > > > > I like Nick's answer to that: int should always return something of > exact type int. Otherwise you're always left wondering whether you > have to do "int(int(x))", or perhaps even "int(int(int(x)))", to be > absolutely sure of getting an int. Agreed.
Perhaps we should start emitting a DeprecationWarning for int subclasses returned from int and index in 3.4?
(I like the idea of an explicit error over implicit conversion to the base type, so deprecation of subtypes makes sense as a way forward. We should check the other type coercion methods, too.)
Cheers, Nick.
Antoine.
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130403/f3c3b3b5/attachment.html>
- Previous message: [Python-Dev] Semantics of __int__(), __index__()
- Next message: [Python-Dev] Semantics of __int__(), __index__()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]