Numeric literals in other than base 10 - was Annoying octal notation
james.harris.1 at googlemail.com
Tue Aug 25 01:23:06 CEST 2009
On 24 Aug, 14:05, Mel <mwil... at the-wire.com> wrote:
> James Harris wrote:
> > On 24 Aug, 02:19, Max Erickson <maxerick... at gmail.com> wrote:
> [ ... ]
> >> >>> 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.
> That's rather beside the point. Literals don't essentially come from files
> or user input. Essentially literals are a subset of expressions, just like
> function calls are, and they have to be evaluated by Python to yield a
> value. I'm not averse to 32'rst', but we already have
> >>> int ('rst', 32)
Sure but while I wouldn't normally want to type something as obscure
as 32"rst" into a file of data I might want to type 0xff00 or similar.
That is far clearer than 65280 in some cases.
My point was that int('ff00', 16) is OK for the programmer but cannot
be used generally as it includes a function call.
More information about the Python-list