Henk-Jaap Wagenaar <[email protected]> added the comment:
[As a follow-on, should I open a new issue/discuss on python-dev? Willing to
help out with a solution on way or another! I know
https://en.wikipedia.org/wiki/Wikipedia:Chesterton%27s_fence, "In my head" <>
"Should be the case" etc. very much applies.]
In my head
@...
def foo(): pass
is equivalent to
def _foo(): pass
foo = ...()
del _foo
However the following shows this is not the case:
@0
def foo(): pass
throws a syntax error, whereas
def _foo(): pass
foo = 0(_foo)
throws a type error. This might seem silly, but it is still unexpected.
https://docs.python.org/3/reference/compound_stmts.html#grammar-token-decorator
has
decorator ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE
which in my head is
decorator ::= "@" atom NEWLINE
Similarly for classes:
https://docs.python.org/3/reference/compound_stmts.html#class-definitions
inheritance ::= "(" [argument_list] ")"
which allows for keyword arguments (does that make any sense!?). In my head it
is (compare with call:
https://docs.python.org/3/reference/expressions.html#calls)
inheritance ::= "(" [positional_arguments [","] | comprehension] ")"
[Tangentially related, this is how I originally got onto the mailing lists, my
unhappiness with the definition of the for statement
(https://docs.python.org/3/reference/compound_stmts.html#the-for-statement):
for_stmt ::= "for" target_list "in" expression_list ":" suite ["else" ":"
suite]
Which I would expect to be:
for_stmt ::= comp_for ":" suite ["else" ":" suite]
so you could e.g. have if statements.
]
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32012>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com