Bug or feature: double strings as one

Jan Kaliszewski zuo at chopin.edu.pl
Sun Aug 9 13:10:52 EDT 2009


09-08-2009 r <rt8396 at gmail.com> wrote:

> On Aug 8, 12:43 pm, "Jan Kaliszewski" <z... at chopin.edu.pl> wrote:
>> 08-08-2009 Steven D'Aprano <st... at remove-this-cybersource.com.au> wrote:
> ...(snip)
>> I use it very often, e.g.:
>>
>>          afunction('quite long string %s quite long string '
>>                    'quite long string quite long string %s '
>>                    'quite %s long string quite long string'
>>                    % (variable1, variable2, variable3))
>>
>> It seems nicer to me than:
>>
>>          afunction(('quite long string %s quite long string '
>>                     + 'quite long string quite long string %s '
>>                     + 'quite %s long string quite long string')
>>                    % (variable1, variable2, variable3))
>>
>> (Note that multiline-'''-strings are usless in such cases).
>>
>
> uhh? A much better way to handle such a problem is like this...
>
> prompt1 = '''
> Some people like to use %s
> ways of doing things just
> so they can support their %s
> way of coding
> '''

Sorry, you are wrong, '''-way would be usefull only if:

     * you want to have '\n' in each place where you wrap the
       literal in your code,

and

     * you use '''-literal at a module (non-indented) level

       or you need not only '\n'-s but also indentations
          (dependent on indentation of your code),

       or such ugly indentation is ok for you:

           some indentated code...
           prompt = '''quite long string %s quite long string
''' quite long string quite long string %s
''' quite %s long string quite long string
'''
           some indentated code...


That's why I wrote it's "useless in such cases."

Regards,
*j

-- 
Jan Kaliszewski (zuo) <zuo at chopin.edu.pl>



More information about the Python-list mailing list