[PATCH] RE: J2 decorator grammar

Michael Sparks zathras at thwackety.com
Sun Aug 22 07:35:18 EDT 2004


Michael Sparks wrote:

> On Sun, 22 Aug 2004, Anthony Baxter wrote:
>> On Sun, 22 Aug 2004 01:41:58 +0100 (BST), Michael Sparks wrote
>> > The patch can be found here:
>> >    * http://thwackety.com/decorator_syntax_J2.patch
>>
>> Good to see. There's a few more bits than this that need to be
>> done, though - see http://www.python.org/sf/979728 for the original
>> @decorator patch, this should show you what else needs to be
>> changed.
> 
> Many thanks for the pointer. I'll try and make sure I cover all the bases,
> but I suspect I'll miss something, but I'll try not to :)

One useful thing this has shown up is "decorate" clashes with the test suite
for decorators since it contains:

def funcattrs(**kwds):
    def decorate(func):
        func.__dict__.update(kwds)
        return func
    return decorate

So some other keyword is definitely preferable. Currently I'm swayed heavily
by arguments in favour of "using" since it doesn't make sense to have:

using:
   staticmethod
   memoize
   funcattrs(author="Joe Blogs")

Standing alone - it's pretty clear it *needs* something following. Whereas
"declare" doesn't to a large extent.

For example, the following reads as ambiguious (to someone new)

class Foo:
   declare:
      author("Joe Bloggs")
   def bar(bla):
      pass

To someone new does this mean Joe Bloggs wrote the method or class? The
using version strikes me personally as clearer:

class Foo:
   using:
      author("Joe Bloggs")
   def bar(bla):
      pass

Also, I haven't seen a similar clash to decorate for "using" as yet.

Checking google, I can't find anything that defines a function
"using" (search terms: "def using" python ), but can find a variety
projects (including Pyrex) that define a function called declare (search
terms: "def declare" python).


Michael.




More information about the Python-list mailing list