Skip to content

Commit b7a6910

Browse files
committed
Update README
1 parent ff229ec commit b7a6910

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@ the `Math.sin` in Ruby:
6161
Type conversions from Ruby to Python are automatically performed for numeric,
6262
boolean, string, arrays, and hashes.
6363

64+
### Calling a constructor
65+
66+
In Python, we call the constructor of a class by `classname(x, y, z)` syntax. Pycall.rb maps this syntax to `classname.new(x, y, z)`.
67+
68+
### Calling a callable object
69+
70+
In Python, we can call the callable object by `obj(x, y, z)` syntax. PyCall.rb maps this syntax to `obj.(x, y, z)`.
71+
72+
### Passing keyword arguments
73+
74+
In Python, we can pass keyword arguments by `func(x=1, y=2, z=3)` syntax. In pycallrb, we should rewrite `x=1` to `x: 1`.
75+
76+
### The callable attribute of an object
77+
78+
Pycall.rb maps the callable attribute of an object to the instance method of the corresponding wrapper object. So, we can write a Python expression `obj.meth(x, y, z=1)` as `obj.meth(x, y, z: 1)` in Ruby. This mapping allows us to call these attributes naturally as Ruby's manner.
79+
80+
But, unfortunately, this mapping prohibits us to get the callable attributes. We need to write `PyCall.getattr(obj, :meth)` in Ruby to get `obj.meth` object while we can write `obj.meth` in Python.
81+
6482
### Specifying the Python version
6583

6684
If you want to use a specific version of Python instead of the default,

0 commit comments

Comments
 (0)