[Python-ideas] Silent bugs - was Re: PEP8 operator must come before line break

Random832 random832 at fastmail.com
Thu Apr 14 18:36:55 EDT 2016


On Thu, Apr 14, 2016, at 16:30, Erik wrote:
> However, that doesn't answer my question of when a line consisting of 
> just "+ expr" is a useful thing.

Well, it's a legitimate unary operator. I've never heard a good
explanation of what the point of it is, but the same can't be said
obviously for -expr.

As for allowing an expression on its own (sure, any operator _can_ have
side effects, but calling most operators for their side effects is a
huge stylistic problem with the code regardless)... the same can be said
for most operators, not just the unary + and -. It'd probably be
reasonable to make a static checking tool that gives you warnings if
almost any non-function-call expression is used as a statement. (along
with other things like most constructors, pure functions, etc). But I
think the idea of making it a syntax error has actually been brought up
recently and rejected.


More information about the Python-ideas mailing list