[Python-Dev] new syntax for wrapping (PEP 318)

Michael Hudson mwh at python.net
Fri Feb 20 06:24:18 EST 2004


"Jewett, Jim J" <jim.jewett at eds.com> writes:

> Bob Ippolito:
>
>> Also note that the patch also adds the same sugar to classes,
>
> Michael Hudson:
>
>> FWIW, I'm rather less convinced this is useful.
>
> On the other hand, it seems arbitrary to say that you can do 
> this with one type of definition, but not another.

Well, this is the argument that got me to add it to the patch; so this
is the argument that I'm not so sure of.  However, if Phillip et
al. do have uses for class wrappers, then I'm happier with the idea.

When I said "less convinced this is useful" that's actually precisely
what I meant!

> Phillip J. Eby:
>
>> class Foo(object) [instancesProvide(IFoo)]:
>
> [is more useful for]
>
>> class Foo(object):
>>      protocols.advise(instancesProvide=[IFoo])
>
>
> I think this may be one reason this didn't happen before;
> wrapping is good, but it isn't entirely obvious how to
> write it or exactly what it should mean.  Given that, it
> might be premature to use up the [] syntax.

I'm not sure what you mean here.

BTW,

class C [decorator]:
 pass

*HAS* to mean

class C:
 pass
C = decorator(C)

and not be "another way to spell __metaclass__", because otherwise
having more than one decorator becomes a nonsense.

This applies less to the 'as' syntax (which I don't like as much for
as-far-as-I-can-tell irrational reasons) so much, but that should
still mean the same thing.

> This might be a good use of macros ... but I have a feeling they
> won't appear quickly.

You don't say! <wink>

Cheers,
mwh

-- 
  The Internet is full.  Go away.
                      -- http://www.disobey.com/devilshat/ds011101.htm



More information about the Python-Dev mailing list