2

I'm new to sympy and and would like to check if an argument is a sympy integer or of type mul. normally, you could do this using:

if ( isinstance(arg, int):
    // do stuff

I want to do something like:

if( isinstance(arg, Integer):
    // do stuff

or

if( isinstance(arg, sympy.core.mul.Mul):
    // do stuff

Thank you!

Justice O.
  • 1,213
  • 12
  • 19

1 Answers1

0

What you are doing is correct.

In [14]: from sympy import *

In [15]: a = 2*Symbol('x')

In [16]: isinstance(a, Mul)
Out[16]: True

In [17]: a = 2 + Symbol('x')

In [18]: isinstance(a, Add)
Out[18]: True
Sudhanshu Mishra
  • 2,024
  • 1
  • 22
  • 40