Try using parse_expr from sympy.parsing.sympy_parser.

Aaron Meurer

On Tue, Apr 22, 2014 at 3:04 PM, Amit Saha <[email protected]> wrote:
> Hello,
>
> Consider the following:
>
>>>> expr=input('Enter a mathematical expression: ')
>
> Enter a mathematical expression: x**2 + 3x + x**3 + 2x
>
>>>> expr = sympify(expr)
>
> Traceback (most recent call last):
>
> File "<pyshell#146>", line 1, in <module>
>
> expr = sympify(expr)
>
> File "/usr/lib/python3.3/site-packages/sympy/core/sympify.py", line
> 180, in sympify
>
> raise SympifyError('could not parse %r' % a)
>
> sympy.core.sympify.SympifyError: SympifyError: "could not parse 'x**2
> + 3x + x**3 + 2x'"
>
>
> Is it possible to get a more specific error message here? Like which
> of the terms are invalid, for example?
>
> Thanks,
> Amit.
>
>
> --
> http://echorand.me
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/CANODV3kj5wSJPX4NhtGTkHVmNzn7fe4XSwnFo95PFJ2pTZ8r6w%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2B6gU5sBGoCXEcjJ%3DeXLpr5%3DyDjGxykbi9YZqOz3Rvp%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to