[Python-ideas] Make keywords KEYwords only in places they would have syntactical meaning
rhodri at kynesim.co.uk
Fri May 18 07:29:12 EDT 2018
On 18/05/18 12:22, Ken Hilton wrote:
> My idea is to only treat keywords as having special meaning when they're in
> the right place. So the following would all be legal:
> >>> from operator import and
> >>> var = and(True, False)
> >>> var
> >>> var = True and False
> >>> var
> >>> def except(exc, def):
> ... try:
> ... return def()
> ... except exc as e:
> ... return e
> >>> except(ZeroDivisionError, lambda: 1/0)
> ZeroDivisionError('division by zero',)
> >>> except(ZeroDivisionError, lambda: 0/1)
> >>> import asyncio as await #this is already currently legal, but will
> not be in the __future__
> >>> async def async(def):
> ... return await await.get_event_loop().run_in_executor(None, def)
> And so on.
> What are your thoughts?
I asked about this earlier, much less clearly, and didn't get a helpful
answer. I haven't had the spare time to look at the parser since then
to see if it's plausible.
Though seriously, your example with "except()" makes me want to recant!
Rhodri James *-* Kynesim Ltd
More information about the Python-ideas