We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9353b5d commit d362f65Copy full SHA for d362f65
1 file changed
src/libpython_clj2/python.clj
@@ -626,3 +626,24 @@ user> (py/call-attr inst \"addarg\" 10)
626
(get-attr parent-mod (module-path-last-string item-path))
627
(throw (Exception. (format "Failed to find module or class %s"
628
item-path))))))))
629
+
630
631
+(defmacro def-unpack
632
+ "Unpack a set of symbols into a set of defs. Useful when trying to match Python
633
+ idioms - this is definitely not idiomatic Clojure.
634
635
+ Example:
636
637
+```clojure
638
+user> (py/def-unpack [a b c] (py/->py-tuple [1 2 3]))
639
+#'user/c
640
+user> a
641
+1
642
+user> b
643
+2
644
+user> c
645
+3
646
+```"
647
+ [symbols input]
648
+ `(let [~symbols ~input]
649
+ ~@(for [s symbols] `(def ~s ~s))))
0 commit comments