[IronPython] .NET attributes
Michael Foord
fuzzyman at voidspace.org.uk
Fri Sep 15 06:22:48 PDT 2006
Charlie Moad wrote:
> On 9/14/06, Dino Viehland <dinov at exchange.microsoft.com> wrote:
>
>> We're tentatively thinking that this is a 2.0 feature but if we figured out a syntax we really liked we'd try to get it into 1.1.
>>
>>
>
> It seems as if there are two clean ways to do this in my mind.
>
> 1. Use python2.4's decorator sytax and extend it to allow class and
> class variable attribute declaration. This has the pitfall of
> breaking cpython compatibility with decorators though. At the same
> time, why use decorators when you can use attributes?
>
When this was last discussed on Python-Dev, Guido agreed that class
decorators could go into core Python. (Partly because of the IronPython
usecase.)
The best thing to do (IMHO) is to see if a syntax can be agreed on
Python-Dev, to ensure future compatibility with CPython.
Michael Foord
http://www.voidspace.org.uk/python/index.shtml
> 2. Thinking about this problem brings me back to an elegant solution
> that Philip Eby came up with to allow python2.3 users to use
> decorators for turbogears.
>
> class Root:
> [expose()]
> def method(): ...
>
> Granted special logic has to be added to the decorator method. This
> prompted me to try:
>
> import clr
> clr.AddReference('System.Web.Services')
>
> from System.Web.Services import *
>
> [WebServiceAttribute]
> class Echo(WebService):
>
> [WebMethodAttribute]
> def echo(msg):
> return msg
>
> The advantage here is syntactically correct python. IP could just add
> some special logic to apply the attributes. Another advantage is that
> it matches the sytax of C# attributes. Evil programmers could even
> apply decorators and attributes to a method!
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-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 users
mailing list