Grammar for classes

Joshua Landau joshua.landau.ws at gmail.com
Mon Dec 19 20:34:25 EST 2011


In reading thorough the syntax defined in the
reference<http://docs.python.org/py3k/reference/compound_stmts.html#class-definitions>,
the class statement has surprised me.

It says that the inheritance part of the class can accept comprehensions.
What does this mean?
I've tried:
"class A(x for x in ()): pass"
but this doesn't need the extra clause as "x for x in ()" is an expression,
and thus this evaluates:
"class A(x for x in (),): pass"
although again it won't be a valid class anytime soon.

So what is this clause for?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111220/b78f5fdd/attachment-0001.html>


More information about the Python-list mailing list