Closed PlumpMath closed 3 years ago
ah;; solve set-attrs! sorry ^^;;
No worries @PlumpMath :-).
The create-class pathway is now used heavily in libpython-clj2 all over the place. I will be interested to know if upgrading is an option and repoen if you find any issues.
@cnuernber
(defonce a3py (py/import-module "a3py")) (defonce a3hy (py/import-module "a3hy"))
(defonce imp (py/import-module "imp"))
(defn pyhy-reload [] (py/$a imp reload a3py) (py/$a imp reload a3hy) )
I'm just pythoninit.Create a py module, put it in the site-packages, and call it up from the closure. I've been building classes in closures, and... My hair is going to fall out. kkk; . Maybe... Later, due to libpython-clj. I hope there will be more clarity than hylang.
I read https://github.com/clj-python/libpython-clj/blob/master/test/libpython_clj/classes_test.clj
and use version clj-python/libpython-clj {:mvn/version "2.00-alpha-5"}
and this py code convert clj
(def Person (py/create-class "Person" nil {"init" (py/make-tuple-instance-fn (fn [self name] (py/set-attr! self {"name" name}) nil)) "say_hi" (py/make-tuple-instance-fn (fn [self] (bt/print "hello, my name is") ;;; ? print("asdf %s" % (py/$. self name)) (bt/print (py/$. self name))) ;;; ? print( :arg-converter py/as-jvm :method-name "say_hi")}) )
Thanks~!