You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CLR operator and Python operator are not bound #906
While trying to use the add operator with two CLR classes (structs, actually), I ran into trouble. I expect the + operator to work in Python like it would in C#, but instead it raises an exception.
>>>importsys>>>importclr>>>sys.path.append('path/to/libs')
>>>clr.AddReference('LibreMetaverse') # Contains OpenMetaverse namespace<System.Reflection.RuntimeAssemblyobjectat0x0000023EB7403CC0>>>>fromOpenMetaverseimportVector3>>>a=Vector3(1.0, 2.0, 3.0)
>>>b=Vector3(2.0, 4.0, 6.0)
>>>a+b# Results in an error...
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'Vector3' and 'Vector3'
>>>str(Vector3.Add(a, b)) # But this works!'<3, 6, 9>'
The Vector3 struct contains
...
public static Vector3 Add(Vector3value1,Vector3value2){value1.X+=value2.X;value1.Y+=value2.Y;value1.Z+=value2.Z;returnvalue1;}
...
public static Vector3 operator+(Vector3value1,Vector3value2){value1.X+=value2.X;
value1.Y+=value2.Y;
value1.Z+=value2.Z;returnvalue1;}
...
For now, pythonnet just not support the operator, I made a PR with this #907 , but some code is conflict with master, thus this PR may not merge, but I think we will support the operator in the future.
Activity
[-]CLR operator not binding to Python operator[/-][+]CLR operator and Python operator are not bound[/+]amos402 commentedon Jul 5, 2019
For now, pythonnet just not support the operator, I made a PR with this #907 , but some code is conflict with master, thus this PR may not merge, but I think we will support the operator in the future.