Ok, I've found the solution!
I need to put the formula *inside* of *quotes*. And then pass it through
*simplify* or *expand* functions.
The error will have such code:
*OtherError: <class 'sympy.core.sympify.SympifyError'>*
Thanks
Mike
czwartek, 11 lutego 2021 o 11:25:06 UTC+1 Michał Pawłowski napisał(a):
> Hi.
>
> I'd like to manage situation, when the formula, which I'd like to process
> has syntax error.
>
> I tryied to use *try except* blocks, but its doesn't work, how can I
> achieve it?
>
> #!/usr/bin/python3
>
> from sympy import *
>
> x = Symbol('x')
>
> try:
> val_1 = x*sin(x)**2+x*cos(x)**2*
> except SyntaxError:
> print('SyntaxError')
> except:
> print('OtherError')
>
> Thanks
> Mike
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/5979f86f-f838-407a-8e85-174a987935e7n%40googlegroups.com.