Comments (2)
You should be able to use the dict by calling its Python methods using callAttr. For example:
PyObject d = /* something returning the dict described above */;
String name = d.callAttr("get", "name").toString();
int age = d.callAttr("get", "age").toJava(int.class);
Or to iterate through the dict:
PyObject keys = py.getBuiltins().callAttr("list", d.callAttr("keys"));
int len = keys.callAttr("__len__").toJava(int.class);
for (int i = 0; i < len; i++) {
String key = keys.callAttr("__getitem__", i).toString();
String value = d.callAttr("get", key).toString(); // or .toJava(...)
}
Of course it would be much easier if we could access Python containers through the corresponding Java interfaces. We may implement that in the future, so let's leave this issue open to track it.
from chaquopy.
Chaquopy 5.1.2 adds the following methods to PyObject
:
- asList
- asMap
- asSet
from chaquopy.
Related Issues (20)
- OSError: Can't get source for <function swish_jit at 0x72d59118b0>. TorchScript requires source access in order to carry out compilation, make sure original .py files are available. HOT 2
- Could not resolve all artifacts for configuration ':classpath'. HOT 1
- Add support for Android Gradle plugin 8.6 HOT 1
- Remove support for buildPython version 3.8
- will u please to add duckdb,netcdf4,xarray packages? HOT 1
- Install of openai is failing with some issues related to jiter HOT 4
- Unable to install opencv-contrib-python HOT 1
- TomlError when building with pybase64 HOT 1
- jpype HOT 4
- Hope to support the following libraries HOT 7
- Compile Err when installing prophet HOT 2
- Failed to install pyzstd HOT 1
- Can't upgrade numpy library from 1.19 to 1.23.3 HOT 1
- Starting a web server causes the application to close itself HOT 1
- Build is not getting successful while installing pyramid-arima HOT 1
- SciPy for Python 3.11 or later
- [FR] com.chaquo.python should support com.android.dynamic-feature plugin HOT 2
- We need Ctranslate2 plz HOT 1
- Import the cantools library Failed HOT 2
- _ctypes not found 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 chaquopy.