On Tue, 16 Feb 2010 00:11:36 +0800, R (Chandra) Chandrasekhar wrote:

> One other question I forgot to ask is this why is there a terminal 
> backslash in
> 
>> subprocess.call("""\
> 
> Removing the backslash makes the function fail.
> 
> I wonder why, because """ is supposed to allow multi-line strings. I am 
> sorry if this sounds obtuse but that backslash baffles me.

The backslash causes the following newline to be skipped, so the "c" at
the beginning of "convert" is the first character in the string. Without
it, the newline would be the first character, and the .splitlines() would
result in an empty string as the first element in the list.

Example:

> """
= hello
= world
= """.splitlines()
['', 'hello', 'world']
> """\
= hello
= world
= """.splitlines()
['hello', 'world']


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to