clj-python / libpython-clj

Python bindings for Clojure
Eclipse Public License 2.0
1.06k stars 69 forks source link

add convenience macro `def-unpack` #156

Closed behrica closed 3 years ago

behrica commented 3 years ago

(defmacro def-unpack [symbols input]
  `(let [~symbols ~input]
     ~@(for [s symbols] `(def ~s ~s))))

(def-unpack [X y] (load_wine :return_X_y true))

See here for justification: https://clojurians.zulipchat.com/#narrow/stream/215609-libpython-clj-dev/topic/convenience.20macro.20for.20multiple-defs.20.3F

cnuernber commented 3 years ago

Awesome, will do.