Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bidirectional Symbol conversion #11

Open
stevengj opened this issue Mar 14, 2013 · 1 comment
Open

bidirectional Symbol conversion #11

stevengj opened this issue Mar 14, 2013 · 1 comment

Comments

@stevengj
Copy link
Member

Currently, PyObject(s::Symbol) produces a Python string, and convert(Symbol, o) converts a Python string object back into a Symbol. However, automatic type conversion does not work, i.e. convert(PyAny, PyObject(:Foo)) produces "Foo" not :Foo.

One way to fix this might be to define a new Python string subtype, and instantiate this type from PyObject(s::Symbol). That way, it will be usable as a string in Python but convert(PyAny, ...) will be able to detect that it is "really" a symbol and convert it appropriately.

@MilesCranmer
Copy link
Contributor

Just found this issue. How much work would this be to implement? Happy to help.

This has presented quite a few problems in PyJulia interfaces; e.g., SymbolicRegression.jl had to start accepting strings instead of symbols for the API, and do the conversion internally. Likewise using several Julia packages from Python is not possible without manually writing conversion methods with julia.eval(...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants