<div class="gmail_quote">On 20 December 2011 10:55, Robert Kern <span dir="ltr"><<a href="mailto:robert.kern@gmail.com">robert.kern@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">On 12/20/11 1:34 AM, Joshua Landau wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
In reading thorough the syntax defined in the reference<br></div>
<<a href="http://docs.python.org/py3k/reference/compound_stmts.html#class-definitions" target="_blank">http://docs.python.org/py3k/<u></u>reference/compound_stmts.html#<u></u>class-definitions</a>>,<div class="im">

<br>
the class statement has surprised me.<br>
<br>
It says that the inheritance part of the class can accept comprehensions. What<br>
does this mean?<br>
I've tried:<br>
"class A(x for x in ()): pass"<br>
but this doesn't need the extra clause as "x for x in ()" is an expression, and<br>
thus this evaluates:<br>
"class A(x for x in (),): pass"<br>
although again it won't be a valid class anytime soon.<br>
<br>
So what is this clause for?<br>
</div></blockquote>
<br>
I suspect that it's harder to make a grammar rule that allows every kind of expression except for generator expressions than it is just to reuse the "testlist" rule and let the runtime reject the generator object when it goes to construct the class.<span class="HOEnZb"><font color="#888888"><br>

</font></span></blockquote><div><br></div><div>The thing is, as far as I can tell, the grammar would be the same without the added clause. That is because it's a valid grammar anyway. The only exception I can think of is if generators were treated exceptionally. Thus, while I agree it makes complete sense to make it a runtime error, the clause in the specification seems to be fluff.</div>

<div><br></div><div>Also - what is this "testlist" rule thee speaks of?</div><div><br></div><div>I think I'm just going to ignore it for now, as long as it doesn't mean I ignore valid code. Thanks Ian and Robert for the input. Should I file a documentation bug report?</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
-- <br>
Robert Kern<br>
<br>
"I have come to believe that the whole world is an enigma, a harmless enigma<br>
 that is made terrible by our own mad attempt to interpret it as though it had<br>
 an underlying truth."<br>
  -- Umberto Eco<br>
<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br>