Bug or feature: double strings as one
Diez B. Roggisch
deets at nospam.web.de
Fri Aug 7 08:37:48 EDT 2009
durumdara schrieb:
> Hi!
>
> I found an interesting thing in Python.
> Today one of my "def"s got wrong result.
>
> When I checked the code I saw that I miss a "," from the list.
>
> l = ['ó' 'Ó']
>
> Interesting, that Python handle them as one string.
>
> print ['ó' 'Ó']
> ['\xf3\xd3']
>
> I wanna ask that is a bug or is it a feature?
>
> In other languages, like Delphi (Pascal), Javascript, SQL, etc., I
> must concatenate the strings with some sign, like "+" or "||".
>
> This technic is avoid the mistyping, like today. But in python I can
> miss the concat sign, and I got wrong result...
It's a feature. It is sometimes used in cases where you want to split a
longer text into several lines, but without introducing newlines.
like this (the parentheses are there for the parser not to puke):
foo = ("foobarbaz"
"padamm")
It has the potential to produce errors as you have seen them, though.
Diez
More information about the Python-list
mailing list