On 2017-08-10 01:11 PM, Steven D'Aprano wrote:
On Thu, Aug 10, 2017 at 12:39:34PM -0300, Soni L. wrote:
I'm pretty sure I read somewhere that lambdas and generators share their
syntax, and that syntax is already a subset of python syntax. Would it
be too hard to expose that with a "simplified AST" API?
I don't understand what you mean by this.
The syntax for lambda is (roughly):
lambda parameter-list : expression
The syntax for generators is (again, roughly):
def name ( parameter-list ) :
Obviously the generator suite can contain expressions, and both have a
parameter-list. What shared syntax are you referring to, and how is it
Or are you referring to generator expressions, rather than generators?
( expression for target in expression ... )
Obviously a Python expression is a Python expression, wherever it is, so
a lambda can contain generator expressions, and generator expressions
can contain lambdas...
And what do you mean by "simplified AST" API? I'm afraid your comment is
too abstract for me to understand.
Yes, see, both are expressions. Expression AST is a subset of python
AST, so it's a simplified form of the python AST.
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/