<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">And that was indeed wrong. What
actually is happening is that GeneratorExp is the real function in
source code, and the #define just makes that name a private one in
the output. The definition, located in Python-ast.c, looks like:<br>
expr_ty<br>
GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int
col_offset,<br>
PyArena *arena)<br>
{<br>
<br>
In any case, I wasn't far off before, what happens is it builds an
object out of the supplied arguments and hands you back an
expression pointer.<br>
<br>
Dan Uber<br>
<br>
On 5/5/13 9:45 AM, Daniel Uber wrote:<br>
</div>
<blockquote cite="mid:5186708C.7070209@gmail.com" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div class="moz-cite-prefix">Having never looked too deeply into
this my answer might be wrong, but<br>
the line right after the define you found is <br>
expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int
lineno, int<br>
col_offset, PyArena *arena);<br>
<br>
So it looks like it's just an expr_ty. The relevant parts of the
generator are<br>
struct {<br>
expr_ty elt;<br>
asdl_seq *generators;<br>
} GeneratorExp;<br>
which is buried inside _expr definition.<br>
<br>
At the top of the file expr_ty is pointer to struct _expr, which
is basically a union type of all the possible expressions, plus
an expr_kind flag to identify the contents.<br>
In my copy of the header, that definition starts around line
187.<br>
<br>
FWIW, I was looking through a 3.3.1 copy of the source tree, but
it may be similar in 2.x<br>
<br>
Daniel Uber<br>
<br>
<br>
On 5/5/13 7:35 AM, shangyu wrote:<br>
</div>
<blockquote cite="mid:BAY176-W2848A4DFA5B82BE0E3D5DDA3B80@phx.gbl"
type="cite">
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:微软雅黑
}
--></style>
<div dir="ltr">Hi dear all,
<div>I'm reading Python source code and know there is a
transition from CST to AST . Python will call some kind of
function which convert the CST node to a AST node , for
example , in function ast_for_itercomp there is a call
to GeneratorExp . The latter is a macro point to
_Py_GeneratorExp</div>
<div>#define GeneratorExp(a0, a1, a2, a3, a4)
_Py_GeneratorExp(a0, a1, a2, a3, a4)</div>
<div>I can't go further more because I can't find out the
difinition of <span style="font-size: 12pt;">_Py_GeneratorExp
,</span></div>
<div>so , where is the <span style="font-size: 12pt;">_Py_GeneratorExp
? Thanks in advance !</span></div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Chicago mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Chicago@python.org">Chicago@python.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/chicago">http://mail.python.org/mailman/listinfo/chicago</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>