def pure_complex(v, or_real=False):
 (h, t) = v.as_coeff_Add()
 if (not t):
  if or_real:
   return (h, t)
  return
 (c, i) = t.as_coeff_Mul()
 if (i is S.ImaginaryUnit):
  return (h, c)

def pure_complex ( v , or_real = False ) : ( h , t ) = v . as_coeff_Add ( ) if ( not t ) : if or_real : return ( h , t ) return ( c , i ) = t . as_coeff_Mul ( ) if ( i is S . ImaginaryUnit ) : return ( h , c )
return a and b if v matches a + i*b where b is not zero and a and b are numbers .