def __complex__ ( self ) : if self . _t != 99 or self . key != [ 're' , 'im' ] : return complex ( float ( self ) ) return complex ( float ( self . re ) , float ( self . im ) )
python complex object is not subscriptable
Called to implement the built - in function complex () .
def __complex__(self):
        """Called to implement the built-in function complex()."""
        if self._t != 99 or self.key != ['re', 'im']:
            return complex(float(self))
        return complex(float(self.re), float(self.im))