Top.Mail.Ru
Python
? ?
LiveJournal for python.
View:Personal Journal.
View:Friends.
View:Calendar.
Missed some entries? Then simply jump to the previous day or the next day.

Friday, August 6th, 2004

Subject:The @decorator flaws....
Time:2:45 pm.
First of all I must state that I agree with all who think this is un-pythonic.
but considering the facts, I can not do anything about it.... thus to the purpose of this post:


If you go for it, go all the way!!!


I just set up Py2.4a2 and found out the following (can't say I am surprised):

- you can not decorate anything but a function!!


this is a shame, as it would be logical to expect this to work for the following cases:
1) variables/attributes
Example:
class A(object):
    @readonly
    someattr = 0

or
@register_in_store
obj = SomeClass()


2) classes
Example:
@prepare
class A(object):
    someattr = 0


each and every of the above cases currently generates a syntax error.


P.S. I'm thinking of posting this as a bug or feature request (but it needs more thought before I do)....
Comments: Read 11 orAdd Your Own.

LiveJournal for python.

View:User Info.
View:Friends.
View:Calendar.
View:Memories.
Missed some entries? Then simply jump to the previous day or the next day.

Image