Unicode symbol as variable

32 views
Skip to first unread message

Diego Mundo

unread,
Apr 4, 2016, 12:36:41 AM4/4/16
to sympy
Trying to use 'γ' as a custom variable in parse_expr with python 2. ...Is this at all possible? I was able to do it with python 3, but my particular project requires python 2.

Jason Moore

unread,
Apr 4, 2016, 12:39:48 AM4/4/16
to sy...@googlegroups.com
Python 2 does not support unicode variable names:

http://stackoverflow.com/questions/2649544/unicode-identifiers-in-python

Can you paste the code you are trying to execute so we can see what you are trying to do?
On Sun, Apr 3, 2016 at 6:05 PM, Diego Mundo <diego...@gmail.com> wrote:
Trying to use 'γ' as a custom variable in parse_expr with python 2. ...Is this at all possible? I was able to do it with python 3, but my particular project requires python 2.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/834a1f6a-2df9-4084-a833-a7fecb644159%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aaron Meurer

unread,
Apr 4, 2016, 12:50:58 AM4/4/16
to sy...@googlegroups.com
Not without changing how parse_expr works. It uses the syntax of the
Python it runs in, and Python 2 doesn't allow non-ASCII identifiers.
You can make it work with Symbol(u'γ') (i.e., manually wrap it with
Symbol). Or set

Gamma = Symbol(u'γ')

and use Gamma in the code. You can also just use "gamma", but you'll
have to remove it from the default locals ('gamma' defaults to the
gamma function).

Aaron Meurer
> https://groups.google.com/d/msgid/sympy/CAP7f1AjMuOb0iwy6KgxSH%2BnOBsUOZ0WqHxmC3xmNDz5J1-txoQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages