Three Minor Feature Requests for 2.2

James_Althoff at i2.com James_Althoff at i2.com
Wed May 9 13:43:40 EDT 2001


Paul writes:

>> 2.  Amend the syntax for class definitions to optionally accept an empty
>> argument
>> list for superclasses.  This comes up when adding and then later
removing
>> mix-ins.
>>
>>     class C():              # should work as well as class C:
>
>I've wanted this for years but the argument in favor is so weak that I
>don't think Guido would go for it. "I'm too lazy to remove the useless
>parens."

Personally, I think the "lazy" argument is compelling enough.  But the
other argument in favor of "class C():" is that it would be very nice to
have some empathy with programmers new to Python who in relying on
"reasonable consistency" as a cornerstone of the "least surprise" principle
find it strange to see that of the following four choices, neither of the
two "reasonably consistent" ones work:


def spam(): pass     # yes
class Eggs(): pass   # no

def spam: pass       # no
class Eggs: pass     # yes

def spam: pass       # no
class Eggs(): pass   # no

def spam(): pass     # yes
class Eggs: pass     # yes


A function definition that has no arguments *requires* empty paren.s
whereas a class definition that has no base class arguments *forbids* empty
paren.s.

Jim






More information about the Python-list mailing list