Literal concatenation, strings vs. numbers (was: Numeric literals in other than base 10 - was Annoying octal notation)
Ben Finney
ben+python at benfinney.id.au
Sun Aug 23 22:45:25 EDT 2009
greg <greg at cosc.canterbury.ac.nz> writes:
> J. Cliff Dyer wrote:
>
> > What happens if you use a literal like 0x10f 304?
>
> To me the obvious thing to do is concatenate them textually and then
> treat the whole thing as a single numeric literal. Anything else
> wouldn't be sane, IMO.
Yet, as was pointed out, that behaviour would be inconsistent with the
concatenation of string literals::
>>> "abc" r'def' u"ghi" 'jkl'
u'abcdefghijkl'
So, different representations of literals are parsed as separate
literals, then concatenated. To have the behaviour you describe, the
case needs to be made separately that digit concatenation should not be
consistent with the established string literal parsing behaviour.
--
\ “What if the Hokey Pokey IS what it's all about?” —anonymous |
`\ |
_o__) |
Ben Finney
More information about the Python-list
mailing list