[Python-ideas] As-do statements in Python
James Lu
jamtlu at gmail.com
Thu Jul 26 09:41:40 EDT 2018
> 4 - introducing a new keyword is the hardest thing you can ever ask on
> this list.
As is already a keyword from with-as and except-as. Perhaps for compatibility “as” is allowed but discouraged as a variable name, and it’s only interpreted as a keyword when followed by an expression and a colon.
> 3 - Most of the example (and you show it yourself with flask) are
> already possible with a more verbose syntaxe based on decorators
Yup, a more terse syntax puts the programmer’s focus on the right things.
> 2 - This will be tempting to use for callbacks and chaining things,
> leading to the nesting hell we tried very carefully to avoid fom other
> languages. The example for sorted is also kinda twisted.
I do agree as-do could be easily used for callbacks. Could you please clarify what you mean by nesting hell?
Is it better to use as-do where you’d normally pass your own instantiation of a class you create that implements a protocol? It’s always possible to simply pass a bound method of a class you create yourself if you want to keep state.
More information about the Python-ideas
mailing list