[Tutor] Can someone explain this to me please

Jon Paris jon.f.paris at gmail.com
Fri Aug 21 20:04:18 CEST 2015


This code:

import sys
x = sys.maxsize
print ("Max size is: ", x)
y = (x + 1)
print ("y is", type(y), "with a value of", y)

Produces this result:

Max size is:  9223372036854775807
y is <class 'int'> with a value of 9223372036854775808

I was expecting it to error out but instead it produces a value greeter than the supposed maximum while still keeping it as an int. I’m confused. If sys.maxsize _isn’t_ the largest possible value then how do I determine what is?


Jon Paris
jon.f.paris at gmail.com





More information about the Tutor mailing list