[Python.NET] Operator overloading for managed objects
oleksii.bidiuk at gmail.com
Tue Feb 8 10:13:08 CET 2011
I am sorry for repeating the question, but I would like to make sure I am
not overlooking something here. Is this a known limitation that the
operators overloaded in C# are not working from CPython? So far I had
written CPython wrappers for the .NET objects that provide proper operators
implementation which is then redirected to explicit C# calls. While this
provides 'native' CPython experience and gives additional control over the
API exposed to a script (to some extend), it results in extra work, which is
mostly a problem on the long term when both C# and Python equivalents have
to be maintained in parallel.
did anybody have experience with using overloaded operators for managed
> objects? I have a class that have e.g. the operator+ overloaded in C#, but
> that does not seem to be picked up from the Python side. I have tried to add
> overloading using the setattr(MyType, "name", method_name), but it only seem
> to work for the native Python objects and not for the managed objects. In
> both cases I get "TypeError: unsupported operand type(s) for +: 'MyType' and
Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PythonDotNet