Comments (4)
Does this work?
const enumValue = pyodide.runPython(`
from pyodide.ffi import create_proxy
create_proxy(Foo.bar)
`);
from pyodide.
Unfortunately, no; it is still coming out as an integer. :-(
Looking closer at the library I'm calling, they have implemented a enum.IntEnum
, which should be convertible to and from an integer value, and so I'm pretty sure the default behavior of pyodide
would be OK. However, in the function I'm calling they're doing an isinstance
test so I still need the actual enum object to make it work.
That said, I have found a workaround I think is OK:
const locals = {
the_magic_object: pyproxyObjectThatTookALotOfWorkToCreate,
the_enum_int_value: functionThatFiguresOutTheRightValue(),
...allTheOtherVarialblesNeededToCallTheFunction
}
const script = `
from bar import foo
foo_enum = Foo(the_enum_int_value)
the_magic_object.magic_function(foo_enum, ...)
`
pyodide.runPython(script, { locals })
It still may be worthwhile being able to disable translations at times, but I'm not blocked until that is decided and figured out.
Thanks!
from pyodide.
Seems to work for me.
const v = pyodide.runPython(`
from pyodide.ffi import create_proxy
from enum import Enum
class A(Enum):
v = 1
create_proxy(A.v, roundtrip=False)
`);
const f = pyodide.runPython(`
def f(x):
print("x is A.v?", x is A.v)
f
`);
f(v)
Prints x is A.v? True
from pyodide.
I'll have to try again with the roundtrip=False
option.
from pyodide.
Related Issues (20)
- mapbox-earcut
- Allow overriding compile parameters in pywasmcross HOT 1
- Debug pyodide release artifacts (and pyodide build debug support)
- "Building and testing Python packages out of tree" commands need some dev tools installed as prerequisites HOT 4
- Add esbuild-py HOT 4
- Add `PyMuPDF` package
- runPython return missing
- cmake -E capabilities is broken HOT 1
- Release 0.26.0 HOT 5
- datasets (huggingface) HOT 6
- Cannot create a WebGL2 context when using SDL HOT 3
- request to add pandasai HOT 1
- request to add llama-index
- request to add langchain HOT 1
- request to add Boto3 HOT 4
- fastobo
- loadPackage() not to access the file system if the cache already exists HOT 2
- cvxpy-base 1.4.3 HOT 2
- html5_canvas_backend no longer works. HOT 1
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 pyodide.