- Notifications
You must be signed in to change notification settings - Fork750
Closed
Description
Environment
- Pythonnet version: 2.3.0
- Python version: 2.7
- Operating System: Windows 10
Details
I have a C# class library which I use in Python. I have aPoint
class (a code snippet):
public Point(double x, double y){this.x = x;this.y = y;}public override string ToString(){return $"Point({x}, {y})";}
When I work with this class library in Python (in Python shell):
>>> p1 = Point(10,15)>>> p1<Geometry.Point object at 0x000000000558F828>>>> str(p1)'Point(10, 15)'
Because I override theToString()
, when I runstr(p1)
I see my custom view of the object. However, when I just access a variablep1
, then it goes to the__repr__()
method under the hood which gives me ugly<Geometry.Point object at 0x000000000558F828>
.
Is there a method in C# class that is possible to override so thatpythonnet
would use that method when getting the__repr__
?
Metadata
Metadata
Assignees
Labels
No labels