[Tutor] mistaken about splitting expressions over lines
Albert-Jan Roskam
fomcl at yahoo.com
Tue Jun 25 14:52:36 CEST 2013
_______________________________
>From: eryksun <eryksun at gmail.com>
>To: Jim Mooney <cybervigilante at gmail.com>
>Cc: tutor at python.org
>Sent: Tuesday, June 25, 2013 2:14 PM
>Subject: Re: [Tutor] mistaken about splitting expressions over lines
<snip>
>
> >>> a = ('this' # this way
> ... ' string' ' is long') # is more flexible
> >>> a
> 'this string is long'
I did something similar after having read http://docs.python.org/2/howto/doanddont.html, under "Using Backslash to Continue Statements".
But I always use + signs. I didn't know that omitting them also works. Is str.__add__ called then, too?
Isn't this a violation of the 'Explicit is better than implicit(ly concatenate strings)' principle?
>>> a = ('this' +
' string' +
' is long')
>>> a
'this string is long'
More information about the Tutor
mailing list