Bug or feature: double strings as one

kj no.email at please.post
Fri Aug 7 13:35:28 EDT 2009


In <h5h7cu$n4p$00$1 at news.t-online.com> Peter Otten <__peter__ at web.de> writes:

>durumdara wrote:

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

Feature, as others have pointed out, though I fail to see the need
for it, given that Python's general syntax for string (as opposed
to string literal) concatenation is already so convenient.  I.e.,
I fail to see why

x = ("first part of a very long string "
     "second part of a very long string")

is so much better than

x = ("first part of a very long string " +
     "second part of a very long string")

FWIW, C has the same concatenation feature for string literals.
E.g., the following is valid C:

printf("first part of a very long string "
       "second part of a very long string\n");

kynn




More information about the Python-list mailing list