Skip to content

Commit 3e784b6

Browse files
author
Christopher Doris
committed
adds pyhelp, pyprint, pyall, pyany, pycallable
1 parent 200c2b4 commit 3e784b6

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

docs/src/pythoncall.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ pyisinstance
131131
pyhash
132132
pyiter
133133
pynext
134+
pyhelp
135+
pyprint
136+
pyall
137+
pyany
138+
pycallable
134139
```
135140

136141
### Conversion to Julia

src/PythonCall.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ include("convert.jl")
1717
# abstract interfaces
1818
include("abstract/object.jl")
1919
include("abstract/iter.jl")
20+
include("abstract/builtins.jl")
2021
include("abstract/number.jl")
2122
include("abstract/collection.jl")
2223
# concrete types

src/abstract/builtins.jl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Builtin functions not covered elsewhere
2+
3+
"""
4+
pyprint(...)
5+
6+
Equivalent to `print(...)` in Python.
7+
"""
8+
pyprint(args...; kwargs...) = (pydel!(pybuiltins.print(args...; kwargs...)); nothing)
9+
export pyprint
10+
11+
"""
12+
pyhelp(x)
13+
14+
Equivalent to `help(x)` in Python.
15+
"""
16+
pyhelp(x) = (pydel!(pybuiltins.help(x)); nothing)
17+
export pyhelp
18+
19+
"""
20+
pyall(x)
21+
22+
Equivalent to `all(x)` in Python.
23+
"""
24+
function pyall(x)
25+
y = pybuiltins.all(x)
26+
z = pybool_asbool(y)
27+
pydel!(y)
28+
z
29+
end
30+
export pyall
31+
32+
"""
33+
pyany(x)
34+
35+
Equivalent to `any(x)` in Python.
36+
"""
37+
function pyany(x)
38+
y = pybuiltins.any(x)
39+
z = pybool_asbool(y)
40+
pydel!(y)
41+
z
42+
end
43+
export pyany
44+
45+
"""
46+
pycallable(x)
47+
48+
Equivalent to `callable(x)` in Python.
49+
"""
50+
function pycallable(x)
51+
y = pybuiltins.callable(x)
52+
z = pybool_asbool(y)
53+
pydel!(y)
54+
z
55+
end
56+
export pycallable

0 commit comments

Comments
 (0)