from sympy import * i = Idx('i') A = Indexed('A', i) A.free_symbols for a in A.free_symbols: print(type(a))