0

In Python 2 and 3, the following code works.

>>> def f(a):
...     return a
... 
>>> assert f('a' 'b' 'c') == 'abc'

Notice the absence of commas separating the arguments in the call to f().

The ability to optionally use whitespace instead of a + sign to achieve string concatenation in a function invocation seems like a strange feature for Python to have since it would appear to be a source of bugs and confusion. What is the stated purpose of this feature and what does the official documentation recommend regarding its use over the conventional syntax for concatenating strings in function invocation, i.e.,

assert f('a' + 'b' + 'c') == 'abc'
petezurich
  • 9,280
  • 9
  • 43
  • 57
Jesse Hogan
  • 3,075
  • 2
  • 16
  • 17

0 Answers0