And one more question: what sympy expression tree classes have the 'name'
attribute?
пятница, 5 августа 2022 г. в 21:40:08 UTC+3, Anton Makarov:
> Hi there.
> I am trying to test the root of expression tree, for example:
> expr = sympify("somefunc(2-5)")
> if expr.func.name =="somefunc":
> call_func_1()
> else:
> call_func_2()
>
> It works just fine, but when I change the expression, for example, to
> expr = sympify("5+6")
>
> Code throws the exception, with error:
> AttributeError: type object 'Add' has no attribute 'name'
>
> I don't understand, why Add class has no attribute "name". Or what
> attribute has all the classes, so I can test the head of any expression
> without code exception?
>
> What code should I write ?
>
--
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/e431ab63-4df4-4231-aba1-3f621f726860n%40googlegroups.com.