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

Cameron Simpson cs at zip.com.au
Thu Apr 4 00:07:14 CEST 2013


On 03Apr2013 14:47, Hrvoje Niksic <hrvoje.niksic at avl.com> wrote:
| On 04/03/2013 01:17 PM, Nick Coghlan wrote:
| Why would one want to be absolutely sure of getting an int?

So that arithmetic can be relied upon? If a subclass can override
the add methods etc it can look like an int, be a subclass instance
of an int, and yet not act like an int in all ways.

If I go int(x), I personally want a real int out the end of it.
-- 
Cameron Simpson <cs at zip.com.au>

Q: What's the difference between a psychotic and a neurotic?
A: A psychotic doesn't believe that 2 + 2 = 4.  A neurotic knows it's true,
   but it bothers him.


More information about the Python-Dev mailing list