Numeric literals in other than base 10 - was Annoying octal notation
Max Erickson
maxerickson at gmail.com
Sun Aug 23 21:19:53 EDT 2009
"bartc" <bartc at freeuk.com> wrote:
>
> "Scott David Daniels" <Scott.Daniels at Acm.Org> wrote in message
> news:kN2dnSZR5b0BWAzXnZ2dnUVZ_s-dnZ2d at pdx.net...
>> James Harris wrote:...
>>> Another option:
>
> It can be assumed however that .9. isn't in binary?
>
> That's a neat idea. But an even simpler scheme might be:
>
> .octal.100
> .decimal.100
> .hex.100
> .binary.100
> .trinary.100
>
> until it gets to this anyway:
>
> .thiryseximal.100
>
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
max
More information about the Python-list
mailing list