Disclaimer: Sensible semantics do dictate that the LHS of as behaving differently depending on the RHS lexeme is ludicrous. But I am curious nontheless.
Hi guys,
Simple question, but one that somone may be able to answer better than my hack. I'm currently messing with metaclasses etc and working out a comfortable syntax for some things.
Given the Python with ... as ...:
statement, can I access in the context manager what name(s) are given on the right of as
:
with foo('fido') as Dog:
...
Can foo.__enter__()
find out the lexeme where Dog
is?
Super bonus credit: Keep it implementation agnostic, supporting Python 3.x too.