[Python-Dev] Requesting that a class be a new-style class
aleax at aleax.it
Sat Feb 19 08:55:44 CET 2005
On 2005 Feb 19, at 06:03, Nick Coghlan wrote:
> This is something I've typed way too many times:
> Py> class C():
> File "<stdin>", line 1
> class C():
> SyntaxError: invalid syntax
> It's the asymmetry with functions that gets to me - defining a
> function with no arguments still requires parentheses in the
> definition statement, but defining a class with no bases requires the
> parentheses to be omitted.
Seconded. It's always irked me enough that it's the only ``apology''
for Python syntax you'll see in the Nutshell -- top of p. 71, "The
syntax of the class statement has a small, tricky difference from that
of the def statement" etc.
> Which leads in to the real question: Does this *really* need to be a
> syntax error? Or could it be used as an easier way to spell "class
-0 ... instinctively, I dread the task of explaining / teaching about
the rationale for this somewhat kludgy transitional solution [[empty
parentheses may be written OR omitted, with large difference in
meaning, not very related to other cases of such parentheses]], even
though I think you're right that it would make the future transition to
3.0 somewhat safer.
More information about the Python-Dev