[IronPython] .NET Attribute None
Dino Viehland
dinov at exchange.microsoft.com
Fri Jun 30 19:22:29 CEST 2006
If you get the "ReflectedProperty (it's repr is <property# ...>", and you can also get it via the type object - it's the descriptor which controls access to the property) you can call it via __get__ and __set__. That's a little cumbersome:
fooType.propertyX.__get__(fooInstance, fooType)
or
fooType.propertyX.__set__(fooInstance, value)
I actually checked in a change this morning which also exposes GetValue and SetValue methods on this for use when you have an interface that defines a property, that property gets explicitly implemented on a type, and the property name collides w/ a property name that's not explicitly implemented - although they're available on all reflected properties now.
So that's how you can make it actually do something. ReflectedField's are similar, but they don't have the collision problem so we won't expose GetValue/SetValue on them.
-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Friday, June 30, 2006 10:10 AM
To: Discussion of IronPython
Subject: Re: [IronPython] .NET Attribute None
Dino Viehland wrote:
> You could use getattr / setattr to access this off the type:
>
> getattr(enumType, 'None')
>
Thanks
> (we do have a bug on this but currently it's marked as low priority so we may or may not get to fixing this for 1.0).
>
>
Take your time. :-)
By the way, interesting things happen if you access .NET object properties via their __dict__. You can get a reference to the property, and its getter and setter. I failed to get the property to *do anything* though.
Michael
http://www.resolversystems.com
http://www.voidspace.org.uk/python/index.shtml
> -----Original Message-----
> From: users-bounces at lists.ironpython.com
> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
> Sent: Friday, June 30, 2006 9:37 AM
> To: Discussion of IronPython
> Subject: [IronPython] .NET Attribute None
>
> Hello all,
>
> We are using some third party .NET classes. One of these defines an enumeration with various members, one of which is "None".
>
> In CPython "object.None" would not be a valid identifier, however in
> IronPython this works fine. Believe me, we don't want you to fix this.
> :-)
>
> However, if this did become invalid how would we access the property ?
>
> All the best,
>
> Michael Foord
> http://www.resolversystems.com
> http://www.voidspace.org.uk/python/index.shtml
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
More information about the Ironpython-users
mailing list