Skip to content

Commit 9dbec34

Browse files
committed
apply final suggestions
1 parent 1f99677 commit 9dbec34

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/user/Interoperability.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ An example in this sense are the `numpy` numeric types (for example, `numpy.int3
255255
### Usage Examples
256256

257257
#### Interop Behavior
258+
258259
A simple `register_interop_behavior` API is available to register interop behaviors for existing types:
259260

260261
```python
@@ -381,15 +382,16 @@ register_interop_type(foreign_class, MyPythonClass)
381382

382383
print(my_java_object.get_tuple()) # (42, 17)
383384
print(type(my_java_object)) # <class 'polyglot.Java_org.example.MyJavaClass_generated'>
384-
print(type(my_java_object).mro()) # [generated_class, MyPythonClass, foreign, object]
385+
print(type(my_java_object).mro()) # [polyglot.Java_org.example.MyJavaClass_generated, MyPythonClass, foreign, object]
385386

386387
class MyPythonClassTwo:
387388
def get_tuple(self):
388389
return (self.getY(), self.getX())
390+
389391
def __str__(self):
390392
return f"MyJavaInstance(x={self.getX()}, y={self.getY()}"
391393

392-
# If 'allow_method_overwrites=False' or not given, this would lead to an error due to the method conflict of 'get_tuple'
394+
# If 'allow_method_overwrites=True' is not given, this would lead to an error due to the method conflict of 'get_tuple'
393395
register_interop_type(foreign_class, MyPythonClassTwo, allow_method_overwrites=True)
394396

395397
# A newly registered class will be before already registered classes in the mro.

0 commit comments

Comments
 (0)