[IronPython] .NET attributes
fuzzyman at voidspace.org.uk
Fri Sep 15 17:00:19 CEST 2006
Charlie Moad wrote:
> On 9/15/06, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
>> Charlie Moad wrote:
>>>> Take away decorator support and you'll lose at least this Python
>>>> Decorators and attributes have at least some commonality, which is why
>>>> this syntax ended up in Python in the first place...
>>>> Allowing decorator syntax in places CPython doesn't is better than not
>>>> allowing it where it does...
>>> So it sounds like people want decorator syntax for attributes. Would
>>> it be sufficient to check for inheritance from System.Attribute to
>>> distinguish the two?
>> Sounds very good.
>>> Also attributes being classes and decorators
>>> functions might help.
>> Can't CPython decorators also be classes (I haven't tried this) ?
> Callable classes I suppose....
(Oops... put my sig in the middle of the code.)
You mean instances...
I meant something like this, which works in CPython and is a good way of
implementing the descriptor protocol :
def __init__(self, function):
self.function = function
def __call__(self, *args, **keywargs):
return self.function(*args, **keywargs)
Provide '__get__' and friends to implement the descriptor protocol on a
function. My guess is that this is pretty much how class methods become
bound methods on instances.
> users mailing list
> users at lists.ironpython.com
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.4/448 - Release Date: 14/09/2006
More information about the Ironpython-users