[Python-ideas] As-do statements/anonymous blocks in python

Rhodri James rhodri at kynesim.co.uk
Thu Jul 26 07:43:44 EDT 2018


On 25/07/18 18:07, James Lu wrote:
> I'm open to any changes or criticism.
> 
> ```
> import atexit
> as atexit.register:
>      # ...do various cleanup tasks...
>      print('Goodbye')
> 
> # is approximately equivalent to =>
> import atexit
> def _():
>      # ...do various cleanup tasks...
>      print('Goodbye')
> atexit.register(_)
> 
> # flask example
> @app.route("/")
> def hello():
>      return "Hello World!"
> # is approximately equivalent to =>
> as app.route('/'):
>      return "Hello World!"

Could you explain what you expect "as" to do *in words* please?  These 
two examples give me conflicting ideas of what you mean.

-- 
Rhodri James *-* Kynesim Ltd


More information about the Python-ideas mailing list