Skip to content

Commit 1ce5b7c

Browse files
committed
use more idiomatic interop
1 parent 853a336 commit 1ce5b7c

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/clojure_python/core.clj

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
and the others are objects to import from this library"
3737
([] nil)
3838
([lib] ; import a library
39-
`(do (. clojure-python.core/interp exec (str "import " ~(name lib)))
40-
(def ~lib (. (. (. clojure-python.core/interp getLocals)
41-
__getitem__ ~(name lib))
42-
__dict__))
39+
`(do (.exec *interp* (str "import " ~(name lib)))
40+
(def ~lib
41+
(-> *interp*
42+
.getLocals
43+
(.__getitem__ ~(name lib))
44+
.__dict__))
4345
(print ~lib)))
4446
([lib object] ; import object from a library
45-
`(do (def ~object (.__finditem__
46-
~lib
47-
~(name object)))
47+
`(do (def ~object (.__finditem__ ~lib ~(name object)))
4848
(print ~object)))
4949
([lib object & more-objects] ; import multiple objects
5050
`(do (py-import ~lib ~object)
@@ -103,18 +103,16 @@
103103
"access 'PyObjectDerived' items as Lazy Seq"
104104
[pyobj] (lazy-seq (.__iter__ pyobj)))
105105

106-
(defn java2py
107-
"to wrap java objects for input as jython, and unwrap
108-
Jython output as java (thanks to Marc Downie on Clojure
109-
list for suggesting this)"
106+
(defn- java2py
107+
"to wrap java objects for input as jython, and unwrap Jython output as java"
110108
[args]
111109
(into-array
112110
org.python.core.PyObject
113111
(map
114112
(fn [n] (. org.python.core.Py java2py n))
115113
args)))
116114

117-
(defn call
115+
(defn- call
118116
"The first len(args)-len(keywords) members of args[]
119117
are plain arguments. The last len(keywords) arguments
120118
are the values of the keyword arguments."

0 commit comments

Comments
 (0)