syntax - Why can you omit the surrounding parentheses for generators in Python when passing it into a function? -


i experimenting in python different syntax passing in generator argument function, , realized although i've been doing this,

>>> sum((j j in xrange(5))) 10 

this works well:

>>> sum(j j in xrange(5)) 10 

this tested on python 2.6.6 on linux. what's going on under hood? syntactic sugar? after all, unwrapped generator indecipherable interpreter:

>>> j j in xrange(5)   file "<stdin>", line 1     j j in xrange(5)         ^ syntaxerror: invalid syntax 

i'm sure reading python grammar answer question.

if prefer plain english on grammars: pep-289 explains it.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -