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

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -