I also wanted to add:
If
@a, b, c
def func(): ...
was prohibited (i.e. you must use parentheses) because [it looks like] it
doesn't make any sense, shouldn't be also the case that any expression with
spaces should be parenthesized? Because this looks equally "wrong":
@a + b * c**d % e
def func(): pass
Granted, there is no rule resembling this anywhere else in Python, but
maybe an exception can be made here, to keep it consistent with the above?
On Sat, 19 Sep 2020, 03:53 Paolo Lammens,
I was referring more to the fact that you don't need parentheses around that—if I remove the leading space, it looks like @ is an operator that operates on the first `Spam()`:
@Spam() + Spam() def func() pass
while instead it's just part of the (compound) statement syntax for function definition.
If one had to think of @ as an operator, it would be a unary operator of the absolute lowest priority. So, from a code style perspective, should we add a space between it and the expression? This should be discussed and added to PEP8, it's a very transcendental matter! ;)
On Sat, 19 Sep 2020, 03:45 Christopher Barker,
wrote: On Fri, Sep 18, 2020 at 3:50 PM Paolo Lammens
wrote: class Spam:
def __add__(self, other): return self
def __call__(self, f): return f
@ Spam() + Spam()
def func():
pass
I think so, yes.
That looks hella weird XD
Indeed it does, but you can do all kinds of other "weird" stuff with callables -/ they are objects like any other, and this can be the result of virtually any expression.
-CHB
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/UVFUGO...
Code of Conduct: http://python.org/psf/codeofconduct/
-- Christopher Barker, PhD
Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
-- Christopher Barker, PhD
Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython