A decorator syntax not yet mentioned (I think!)

Mark Bottjer mark_bottjer at hotmail.com
Thu Aug 12 20:08:38 EDT 2004


Jeff Shannon wrote:
> Mark Bottjer wrote:
>> BTW: "ISTM"?
> 
> "... it seems to me ..."  :)

Ah! GTK :)

> I'd be happiest with this option, too.  But it seems that GvR has 
> already ruled out anything other than prefix syntax, so I'm not 
> wasting my energy backing this.

That's why I hadn't mentioned it before now, either. Not much point.

> With prefix syntax as a given, I'd prefer to have the closest we can 
> come to this form, which is to have the meta (or decorate, or 
> whatever) block immediately preceding the def.

Personally, I think that the most "Pythonic" prefix form would be:

class C:
   decorate (d1, d2, d3):
     def f(self):
       pass

But down that road lies madness... *ducks*

> Though I must say, I don't see how putting a meta: block inside the 
> function is any less a violation of established patterns than having 
> it outside the function.  You seem to be implying that you think it's
>  fine inside, but an abomination outside.

Not an abomination, no. I just think it fits better inside. It's nicely 
scoped, it's contents are well delineated, it doesn't couple with the 
next statement at the same indentation level, and plays nicely with 
where we already look for the docstring (for now). Of course, it couples 
with the outer scope, but docstrings already set the precedent for that.

It just seems more "Pythonic" to me to have it inside, is all.

> I'm saying that this sort of block structure is (IMO) the most
> pythonic way to do this, and while I'd like it inside I don't
> particularly care if it's outside, and that in any case it's far less
> of an abomination that @pies are.  :)

There's that word again... :)

   -- Mark



More information about the Python-list mailing list