Integer conversion

Colin J. Williams cjw at sympatico.ca
Sat Jun 15 08:25:59 EDT 2002


int(string, base) => integer

For int('127',  8), I had expected this function to deliver 87.

The example below correctly gives errors at the top and bottom of the
range and
for int('127', 10) delivers 127.  The other cases are not what I
expected.

I would appreciate any suggestions.

Colin W.

for b in range(2,38):
  try:
    print b, '[', int('127', b), ']'
  except:
    pass
    print 'error'




More information about the Python-list mailing list