-
Notifications
You must be signed in to change notification settings - Fork 103
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
Creating symbols from Python #156
Comments
Call the Julia |
>>> import julia
>>> jul = julia.Julia()
>>> jul.Symbol("x")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Julia' object has no attribute 'Symbol'
>>> jul.symbol("x")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Julia' object has no attribute 'symbol' |
That's #144. For now you probably need But a separate problem is that it might convert it back to a string when it returns the value to Python, since PyCall by default converts Julia Symbols to Python strings. |
In Julia, you would currently have to do (I'm guessing slightly here because I don't use pyjulia myself, so I'm working off of how I remember it working and how PyCall works in Julia.) |
>>> jul.eval("a=:x")
'x'
>>> jul.eval("typeof(a)")
<PyCall.jlwrap Symbol> I can use that to define a
This is only going to be used Python->Julia, so it's safe. I think I got all I need now, other than JuliaPy/PyCall.jl#497 and the tag. It worked out surprisingly smooth. |
I know this is an old thread but this works for me, thanks!
|
Is this possible? I would like a user to be able to pass a symbol from Python to a Julia API. Do I instead need to implement a conversion from a string for comparisons? That sounds dangerous.
The text was updated successfully, but these errors were encountered: