Skip to content

Commit 181a4f5

Browse files
committed
Adding back attr-type-map
1 parent a35d737 commit 181a4f5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/libpython_clj2/python.clj

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ user> (py/py. np linspace 2 3 :num 10)
4646
"Initialize the python library. If library path is not provided, then the system
4747
attempts to execute a simple python program and have python return system info.
4848
49-
Note: all of the options passed to `initialize!` may now be provided in
49+
Note: all of the options passed to `initialize!` may now be provided in
5050
a root-level `python.edn` file. Example:
5151
5252
```
@@ -82,7 +82,7 @@ user> (py/py. np linspace 2 3 :num 10)
8282
8383
The file MUST be named `python.edn` and be in the root of the classpath.
8484
With a `python.edn` file in place, the `initialize!` function may be called
85-
with no arguments and the options will be read from the file. If arguments are
85+
with no arguments and the options will be read from the file. If arguments are
8686
passed to `initialize!` then they will override the values in the file.
8787
8888
Returns either `:ok` in which case the initialization completed successfully or
@@ -359,7 +359,17 @@ user> (py/py. np linspace 2 3 :num 10)
359359
(defn python-type
360360
"Get the type (as a keyword) of a python object"
361361
[v]
362-
(py-ffi/with-gil (py-proto/python-type v)))
362+
(if v
363+
(py-ffi/with-gil (py-proto/python-type v))
364+
:py-none))
365+
366+
367+
(defn attr-type-map
368+
"Return a map of attr name to python-type of the attribute"
369+
[pyobj]
370+
(py-ffi/with-gil
371+
(into (sorted-map) (map #(vector % (python-type (get-attr pyobj %))))
372+
(dir pyobj))))
363373

364374

365375
(defmacro import-as

0 commit comments

Comments
 (0)