Make 'def' and 'class' usable within expressions
Shane Hathaway
shane at zope.com
Thu Mar 25 10:19:40 EST 2004
Thomas Heller wrote:
> Shane Hathaway <shane at zope.com> writes:
>>> # Define an interface.
>>> ICustomer = Interface(class):
>>> def get_id():
>>> """Return the customer ID"""
>>
>>Today, this would be written as:
>>
>> class ICustomer:
>> def get_id():
>> """Return the customer ID"""
>> ICustomer = Interface(ICustomer)
>
>
> With PEP 318 in place, it would be written as:
>
> class ICustomer [Interface]:
> def get_id():
> """Return the customer ID"""
>
> Hm.
>
> I like the third way best. Why? The 'Interface(class)' idiom confuses
> me. But maybe I'm infected by the PEP 318 virus.
What I don't like about the third alternative is the subtle distinction
between parentheses and square brackets. It seems like newbies would
have a hard time with it, as would advanced programmers who are looking
over a new code base.
Shane
More information about the Python-list
mailing list