Numeric literals in other than base 10 - was Annoying octal notation

Ben Finney ben+python at benfinney.id.au
Sun Aug 23 22:29:20 EDT 2009


Max Erickson <maxerickson at gmail.com> writes:

> At some point, abandoning direct support for literals and just 
> having a function that can handle different bases starts to make a 
> lot of sense to me:
>
> >>> int('100', 8)
> 64
> >>> int('100', 10)
> 100
> >>> int('100', 16)
> 256
> >>> int('100', 2)
> 4
> >>> int('100', 3)
> 9
> >>> int('100', 36)
> 1296

Hah! You don't get me that easily, nobody would make something so simple
and obvious.

Right, guys?

-- 
 \       “When a well-packaged web of lies has been sold to the masses |
  `\    over generations, the truth will seem utterly preposterous and |
_o__)                    its speaker a raving lunatic.” —Dresden James |
Ben Finney



More information about the Python-list mailing list