[Python-ideas] Decorator syntax

ilya ilya.nikokoshev at gmail.com
Fri Sep 4 15:29:30 CEST 2009


I would say here are two more things to consider:

(1) How to colorize expression @a or b and c? My IDE colorizes only @a
as decorator

(2) How to search for all functions that have been applied decorator
`b` (*not* either `a` or `b`)?

(bonus) How to test expression of the above form? By definition, you
will have only *one* function decorated like that. To test it, you
should define it as a separate function anyway.

ilya.

On Thu, Sep 3, 2009 at 3:27 PM, Georg Brandl<g.brandl at gmx.net> wrote:
> MRAB schrieb:
>
>>> I do see a reason.  I have no problems with
>>>
>>>    @foo.bar
>>>    @foo.bar[baz]
>>>    @foo.bar(baz)
>>>
>>> But this is ugly to me:
>>>
>>>    @a + b
>>>    def foo(): pass
>>>
>> Ugly, yes.
>>
>>> As is this:
>>>
>>>    @a or (c and d)
>>>    def foo(): pass
>>>
>> Agreed.
>
> Good :)
>
>>> Having the decorator expression "opened" by @ but not "closed" feels bad.
>>>
>> But:
>>
>>      @foo
>>
>> isn't "closed" either.
>
> Hmm, the above is probably a bad expression of my "feeling" :) but I think
> you know what I mean.
>
> Georg
>
> --
> Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
> Four shall be the number of spaces thou shalt indent, and the number of thy
> indenting shall be four. Eight shalt thou not indent, nor either indent thou
> two, excepting that thou then proceed to four. Tabs are right out.
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



More information about the Python-ideas mailing list