def random_symbols(expr):
 try:
  return list(expr.atoms(RandomSymbol))
 except AttributeError:
  return []

def random_symbols ( expr ) : try : return list ( expr . atoms ( RandomSymbol ) ) except AttributeError : return [ ]
returns all randomsymbols within a sympy expression .