@chris441 Is it possible to evaluate a string of python with libpython-clj
?
What I'm interested in, for the record, is whether I'd be able to make it possible for Oz to execute code blocks of python, as it can with clj code.
You can probably use the eval built-in python function?
@metasoarous run-simple-string
should do that for you. As an FYI, you will often get faster / better response over on Zulip. That's where Clojure data science folks hang out all the time. For example, there have just been a bunch of changes to TMD.
LOL; OK... ok...
I know you guys keep telling me I need to get over there.
I've just been dying from "death by a thousand chat apps"
@neo2551 @jsa-aerial Thank you both though 🙂
@jsa-aerial the crazy stuff is the speed at which the changes happened lol. I think the idea of having datasets acting like maps of sequence is cool.
@metasoarous See https://cljdoc.org/d/cnuernber/libpython-clj/0.4/api/libpython-clj.python#run-simple-string
I'm not so keen on having datasets acting like seqs of maps. As I stated in one of the threads, this is very misleading because they are absolutely nothing like seqs of maps. This 'clojury' kind of interface is handy in someways (for novices) but if you are more a R data.table/dplyr sort (or pandas for that matter) it is confusing. I am moving to just using tablecloth so I don't need to look at this stuff! 😁
I'm a big fan of seq of maps approach; I realize it's in conflict with pandas, but it's actually the thing I don't like about pandas, so it's fine with me 🙂 Somehow, the approach in R seems more reasonable given that it's an array/vector oriented language; Somehow, the decisions come together in a more comprehensive way to me. In python, it feels in conflict with traditional pythonic programming practices, and that conflict has always bugged me.
But to each their own 🙂
So using run-simple-string
you can only get back a 1 or 0. Any way to get a reference to the last evaluated form?
why not just shell out to python if you have straightup python code?
Well, ideally it would be possible to share the same process/environment
It's ok though; I think I can work around it.
Thanks for considering/asking @aaelony!
The big reason to use libpython-clj and not just shell out to python, is that you can then interactively work with python from clj/cljs. This is seriously cool and can be extremely useful - when you can get python to actually work...
I can imagine definging variables in the python code that you might be able to retrieve data from clojure side, but that limits what I was hoping to do somewhat
I think Chris in an much early thread about this (what should the interface look like) had a great point. Which was that TMD was adding an important and orthogonal capability to Clojure. As I stated in one of the recent threads, we don't want to start sliding into 'ORM land', which is very similar to this situation: "why not have RDB databases look and act like objects - if you squint enough, they sort of do, and developers will be happier" (until they aren't).
Yeah, it sucks - but that's Python for you! ¯\(ツ)/¯
Phooey! Thanks for explaining though. I guess for what I want I'll need to have a function you call from python when you want to render/view something.
The way I've been approaching this (R is vastly better at doing it) is to just calculate data on the py side of things and have the result come back to clj/cljs (typically as TMD DS). Then you do any final expl and massaging (say to put it into VGL/VG data shape) in clj/cljs. Not sure if that fits in with what you are doing though