[Python-Dev] Re: Plea for function/method syntax sugar (PEP 318, with a different syntax)

Bob Ippolito bob at redivi.com
Thu Feb 19 11:10:43 EST 2004

On Feb 19, 2004, at 5:42 AM, Paul Moore wrote:

> Bob Ippolito <bob at redivi.com> writes:
>> Some time ago, mwh developed a patch that adds some syntactical sugar
>> to def, which is equivalent to PEP 318 though it has a different and
>> more flexible syntax...
> [...]
>> I'm willing to help however I can in order to get this into Python 
>> 2.4.
> I like Michael's patch (or rather the functionality/syntax it offers),
> but I'd have to admit that it's for purely theoretical "that's nice"
> reasons - I don't have any use cases to add to yours.
> I'm not entirely sure why acceptance got stalled the way it did. While
> I don't recall wholehearted enthusiasm, nor do I recall any other
> proposal getting significant support. My impression was that it ended
> up left hanging "because there might be something better that we're
> missing". The fact that nothing else has been proposed since argues
> either that no-one is interested enough, or that there isn't likely to
> be a better option found. Either way, it's probably time to reopen the
> issue and decide one way or the other.
> As well as the question of whether anyone is interested, there was
> also a question as to whether it is useful enough to justify the
> language change. Your use cases may address these issues to an extent.
> Finally, there was an issue with the fact that the syntax didn't
> handle properties, but personally, I don't see that as a major issue -
> properties are just so different (combining 3 separate functions) that
> I wouldn't expect the same syntax to help in both cases.
> I'd like to see this resolved one way or another, and I'm also willing
> to help - but I'm not sure what needs doing next.

Combining three separate functions is probably done best with a data 
descriptor base class, or using some naming convention and a metaclass 

Also note that the patch also adds the same sugar to classes, so you 
could use it in lieu of metaclasses for some cases (like transforming 
some members that follow a naming convention into properties):

 >>> class Foo(object) [type]:
...   pass
 >>> Foo
<type 'type'>


More information about the Python-Dev mailing list