python - How to get the number of symbols in a SymPy expression -
i trying number of symbols in sympy expression like:
a = sympify('1/4*x+y+c+1/2')
the number instance should 3
. came far
a.args.__len__()
however, counts constant factors 1/4 , 1/2.
any ideas?
you need use atoms
method list symbols in expression.
in [32]: a.atoms(symbol) out[32]: {c, x, y}
Comments
Post a Comment