[Python-Dev] PEP 340 -- Clayton's keyword?

Guido van Rossum gvanrossum at gmail.com
Fri May 6 17:34:42 CEST 2005


[Greg Ewing]
> How about user-defined keywords?
> 
> Suppose you could write
> 
>    statement opening
> 
>    def opening(path, mode):
>      f = open(path, mode)
>      try:
>        yield
>      finally:
>        close(f)
> 
> which would then allow
> 
>    opening "myfile", "w" as f:
>      do_something_with(f)
[etc.]

This one is easy to reject outright:

- I have no idea how that would be implemented, especially since you
propose allowing to use the newly minted keyword as the target of an
import. I'm sure it can be done, but it would be a major departure
from the current parser/lexer separation and would undoubtedly be an
extra headache for Jython and IronPython, which use standard
components for their parsing.

- It doesn't seem to buy you much -- just dropping two parentheses.

- I don't see how it would handle the case where the block-controller
is a method call or something else beyond a simple identifier.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list