[IronPython] special method equivalents in C#

Christian Schmidt Christian2.Schmidt at gmx.de
Thu Aug 10 14:01:38 CEST 2006

I want to implement special methods of classes in C# that I use from 
For example C#'s equivalent of Python's __iter__ is to derive from 
IEnumerable, __getitem__ corresponds to this[object], __init__ and 
__del__ to constructor and destructor, __str__ to toString(), __hash__ 
to getHashCode(), ...

Is there a table of all conversion from C# to Python special methods or 
a general mechanism?
Especially I'm looking for the equivalent of __getattr__. I tried 
__getattr__ in C#, but it didn't get exported in IronPython (atleast it 
wasn't shown in dir(myclass).

Further methods I'm looking for is __nonzero__, __call__, __contains__.

Currently my workaround is to encapsulate the C#-classes in Python 
classes extended by the special methods.

Thanks for any hints.

More information about the Ironpython-users mailing list