decorators as a special case of an @ operator?

Dan Christensen jdc at uwo.ca
Mon Aug 9 15:50:02 EDT 2004


Peter Hansen <peter at engcorp.com> writes:

> Dan Christensen wrote:
>> Is there any reason that python doesn't automatically
>> continue all incomplete binary operators, allowing
>>    x = a_very_long_expression +
>>        another_long_expression
>> ?
>
> Very likely, as is usual with Python, to avoid implicitly
> assuming something that could well be wrong, thus failing
> in a possibly very hard to find way, without warning.
>
> x = a_very_long_expression +
> some_function_that_might_return_a_value()
>
> Now, was the first line a typo, with a missing extra value,
> or was it really intended to add the result of the function
> call on the second line?

Good point.  What if python did automatic continuation in this
situation only if the second line was further indented?

This is ok:

  x = a_very_long_expression +
    some_function_that_might_return_a_value()

This suggests the programmer forget to finish the first line:

  x = a_very_long_expression +
  some_function_that_might_return_a_value()

I just dislike those backslash characters.  And I'm always
afraid there's hidden whitespace after them:

>>> 1 + \  
  File "<stdin>", line 1
    1 + \  
          ^
SyntaxError: invalid token

Thanks for your comments!

Dan



More information about the Python-list mailing list