help() works...
Well, Seo Sanghyeon asked me a pretty reasonable question of the last entry
"Why don't you use help(), instead of printing Overloads?"
Good question, I didn't realise that actually worked in IronPython for .Net types, I was very pleasantly surprised, I remember in the early betas i tried using help() on various managed types and it would just raise a NotImplementedException exception (or something like that, I forget now) - so what does that mean for my examples... well... let's take a system type like Guid and use help() on it.
IronPython 1.0.60816 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import System
>>> from System import *
>>> help(Guid)
Help on Guid in module System in mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089
| Guid(Array[Byte] b)
| Guid(UInt32 a, UInt16 b,
UInt16 c, Byte d, Byte e, Byte f, Byte g, Byteh, Byte i, Byte j,
Byte k)
| Guid(str g)
| Guid(int a, Int16 b, Int16
c, Array[Byte] d)
| Guid(int a, Int16 b, Int16
c, Byte d, Byte e, Byte f, Byte g, Byte h, Byte i, Byte j, Byte
k)
| Guid
CreateInstance[Guid]()
|
| Data and other attributes defined here:
|
| CompareTo(...)
|
int CompareTo(self, object value)
|
int CompareTo(self, Guid value)
| Equals(...)
|
bool Equals(self, object o)
|
bool Equals(self, Guid g)
| Finalize(...)
|
Finalize(self)
| GetHashCode(...)
|
int GetHashCode(self)
| GetType(...)
|
Type GetType(self)
| MemberwiseClone(...)
|
object MemberwiseClone(self)
| NewGuid(...)
|
Guid NewGuid()
| ToByteArray(...)
|
Array[Byte] ToByteArray(self)
| ToString(...)
|
str ToString(self)
|
str ToString(self, str format)
|
str ToString(self, str format, IFormatProvider provider)
| __eq__(...)
|
bool op_Equality(Guid a, Guid b)
| __init__(...)
|
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
|
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
| __ne__(...)
|
bool op_Inequality(Guid a, Guid b)
| __new__(...)
|
__new__(cls, Array[Byte] b)
|
__new__(cls, UInt32 a, UInt16 b, UInt16 c, Byte d, Byte e, Bytef,
Byte g, Byte h, Byte i, Byte j, Byte k)
|
__new__(cls, str g)
|
__new__(cls, int a, Int16 b, Int16 c, Array[Byte] d)
|
__new__(cls, int a, Int16 b, Int16 c, Byte d, Byte e, Byte f,
Byte g, Byte h, Byte i, Byte j, Byte k)
|
Guid CreateInstance[Guid]()
|
>>>
Sweet, it works a treat - and will save a lot of digging time - though you might want to capture the results for big classes ;o)
Thanks Seo!
(btw, Seo is the man behind the Iron Python Community Edition & FePy projects - which can be found on sourceforge) and I would have to agree with this article that he does seem almost OmniPresent in the IronPython community...