File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ To experiment with it:
2020
2121To include as a dependency:
2222
23- Copy the config section found at http://clojars.org/clojure-python into your dependencies in project.clj.
23+ Copy the config section found at http://clojars.org/clojure-python into your dependencies in your project's project.clj.
2424
2525## License
2626
Original file line number Diff line number Diff line change 4747 `(do (import-fn ~lib ~fun)
4848 (import-fn ~lib ~@more-funs))))
4949
50- (defmacro py-fn [lib fun]
50+ (defmacro py-fn
5151 " create a native clojure function applying the python
5252 wrapper calls on a python function at the top level of the library
5353 use this where lambda is preferred over named function"
54+ [lib fun]
5455 `(let [f# (.__finditem__
5556 ~lib
5657 ~(name fun))]
7475 non-keywords (filter (fn [a] (not (keyword? a))) args)]
7576 `(call (__ ~class ~@attrs) [~@non-keywords] ~@keywords))))
7677
77- (defn dir [x]
78+ (defn dir
7879 " it's slightly nicer to call the dir method in this way"
80+ [x]
7981 (seq (.__dir__ x)))
8082
81- (defn iter [o start end]
83+ (defn iter
8284 " Jython sometimes represents things as 'PyObjectDerived', which has no direct method to get their items as a seq"
85+ [o start end]
8386 (for [i (range start end)]
8487 (.__getitem__ o i)))
8588
86- (defn java2py [args]
89+ (defn java2py
8790 " to wrap java objects for input as jython, and unwrap jython output as java
88- (thanks to Marc Downie on Clojure list for suggesting this)"
91+ (thanks to Marc Downie on Clojure list for suggesting this)" [args]
8992 (into-array
9093 org.python.core.PyObject
9194 (map
9295 (fn [n] (. org.python.core.Py java2py n))
9396 args)))
9497
95- (defn call [fun args & key-args]
98+ (defn call
9699 " The first len(args)-len(keywords) members of args[]
97100 are plain arguments. The last len(keywords) arguments
98101 are the values of the keyword arguments."
102+ [fun args & key-args]
99103 (.__tojava__
100104 (if key-args
101105 (.__call__ fun (java2py args) (into-array java.lang.String key-args))
You can’t perform that action at this time.
0 commit comments