[IronPython] DocString for properties

Dino Viehland dinov at microsoft.com
Thu Mar 4 04:27:17 CET 2010


Steve wote:
> Hi guys,
> I've been struggling with getting at the documentation string for a
> static
> property defined in one of my C# classes from IronPython.
> 
> Say my C# class had a public static property that returned an int.
> public class MyClass
> {
>   ///<summary>My property summary</summary>
>   public static int MyProperty{ get{return 1;} }
> }
> 
> If I use the following python script to call help, I get help
> information on
> the int data type (I can understand why this is happening).
> 
> help( MyLib.MyClass.MyProperty )

You'll need to go into the type's dictionary and pull out the actual
descriptor object and access the __doc__ attribute from there.  For
example:

>>> import System
>>> print System.Environment.__dict__['CurrentDirectory'].__doc__

                    Gets or sets the fully qualified path of the current working
 directory.


Get: CurrentDirectory() -> str
Set: CurrentDirectory() = value

>>>




More information about the Ironpython-users mailing list