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

James Harris james.harris.1 at googlemail.com
Mon Aug 24 04:16:07 EDT 2009


On 24 Aug, 02:19, Max Erickson <maxerick... at gmail.com> wrote:

...

> > 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

This is fine typed into the language directly but couldn't be entered
by the user or read-in from or written to a file.

James



More information about the Python-list mailing list