Comments (7)
@davidpham87 sorry for delayed response.
How would you feel about this:
(py. obj **method arg1 arg2 arg3 ... argN kwargs)
where last argument is interpreted as a map?
That same modification would then percolate to
(py.. obj (**method1 arg1 arg2 ... kwargs) (**method2 arg1 arg2 ... kwargs))
or would you prefer
(py. obj **method args kwargs)
?
I could probably also do (py. obj method *args **kwargs)
pretty easily with a little macro magic but I'd like to hear how @cnuernber feels about that.
from libpython-clj.
The last option would be the most flexible.
(py. obj method *args)
would be equivalent to (py. obj method arg1 arg2 arg3 ... argN)
and this could be mixed/matched with
(py. obj method **kwargs)
which would be equivalent to (py. obj method :attr1 val1 :att2 :val2 ... :attrN :valN)
from libpython-clj.
@jjtolton No problem, you have been helping me on Zulip (I am Neo). I don't know which dark magic you use in macro world, but this would be great
(py. obj method **kwargs}) ;; or (py. module fn **{:as kwargs})
but I think
(py.** obj method kwargs) ;;
would be the cleanest of all. It could be just a function wrapping py/call-attr-kw
.
But it would be great with module/function calls like
(np/linspace **{:start 0 :stop 1})
Let's wait on @cnuernber for his opinion.
from libpython-clj.
Alright after thinking it over, (py. obj method *args **kwargs)
LITERAL syntax has a few problems. For instance, *args
and **kwargs
are both valid symbol names, so then I'd need to provide an escape character -- and now things are already getting pretty messy and a bit contraventional to Clojure idioms.
I'll investigate a (py.** method kwargs)
macro and corresponding (py.. obj (**method kwargs))
form.
from libpython-clj.
@davidpham87 please review #57 and let me know if that looks like it will work the way you were expecting :)
from libpython-clj.
Thanks a lot for the work. I really love the syntax. I think though we should not support the multiarities of theses methods as it is counterintuitive. Maybe have an alias for py/call-kw to have the two arities.
The reason it bothers me is the **method variant as change the position of the kwargs (I know it is common in Clojure, but for a specialized library, what do you think of going with the “least amount of surprise” path?
from libpython-clj.
The kwargs is always last in **, which means if you use it with just one arg, that arg will be the kwargs, which would cover your original use-case. I figure that is the arrity that will probably be used most, but now there is an arrity that covers all options. But I’ll ask for some more feedback and see what the consensus is
from libpython-clj.
Related Issues (20)
- Cannot run the example in the tutorial in Cider with JDK 17 HOT 8
- process hanging in embeded mode on exception HOT 2
- from-import does not support "string"
- newbie: I get: `dir already refers to: #'clojure.repl/dir in namespace: user` HOT 2
- Newbie: Lein Clojure Windows Anaconda VSCode Cava REPL Returns (NoClassDefFoundError) HOT 5
- Create Python Module then Import Module and Call Function Inside Clojure? HOT 4
- Fix ubuntu version in dockerfiles HOT 6
- Consider releasing returned values from instance fns
- JDK-20 support HOT 3
- builtins/eval throws 'frame does not exist' HOT 2
- Unable to require libraries from within docker using conda HOT 6
- Failed to find a valid python library on MS-Windows with the official python distributions
- Extend CI coverage to all the mainstream architectures
- require-python missing functions with annotation HOT 3
- Make polyglot development easier by allow require-python to be path-informed HOT 1
- Data transformation pipelines? HOT 1
- NSWindow main thread error when trying to setup Gymnasium (openapi gym) HOT 5
- JVM crashes when requiring `libpython-clj2.require` on 64bit Raspberry Pi 4 HOT 1
- error of unhashable type HOT 15
- Ways to reduce probability of memory leaks? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libpython-clj.