'concatenating''strings'

Grant Edwards grante at visi.com
Thu Aug 8 20:36:46 CEST 2002


In article <mailman.1028830705.2379.python-list at python.org>, Sean 'Shaleh' Perry wrote:
> 
> On 08-Aug-2002 Will Stuyvesant wrote:
>> Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on
>> win32
>> Type "copyright", "credits" or "license" for more information.
>> IDLE 0.8 -- press F1 for help
>>>>> '1''2'
>> '12'
>>>>> '1''2''3'
>> '123'
>>>>> '1'''
>> '1'
>>>>> '''3'
>> KeyboardInterrupt
>>>>> # that did hang with the cursor on the next line so I had to press
>> CTRL-c
>>>>> _
>> '1'
>>>>> ''+'3'
>> '3'
>> 
>> Totally unimportant but unexpected behaviour.
>> Looks like you can not concatenate the empty string '' to 'something'
>> without using the + operator.
> 
> um, zero + N => N.  What should empty string + string yield?
> How would you know that an empty string was there?  The current
> behavior makes perfect sense to me.

The "uexpected behavior" was that he had to hit control-C after
typing 

'''3'

He started a triple quoted string and never closed it.  

'' '3'

works as expected.

-- 
Grant Edwards                   grante             Yow!  I'm a GENIUS! I
                                  at               want to dispute sentence
                               visi.com            structure with SUSAN
                                                   SONTAG!!



More information about the Python-list mailing list