Exemplo n.º 1
0
    def __eq__(self, other):
        """ Two Primitives are equal iff their all their properties are equal.
        Consider bound and unbound methods equal. """
        # other is a Primitive
        if isinstance(other, Primitive):
            return (self == other.func and
                    self.return_type == other.return_type and
                    self.arg_descs == other.arg_descs and
                    self.kwarg_descs == other.kwarg_descs and
                    self.call_afterwards == other.call_afterwards and
                    self.export_me == other.export_me)

        # other is a callable
        elif callable(other):
            if is_instancemethod(self.func) != is_instancemethod(other):
                return False
            elif is_instancemethod(self.func):  # and is_instancemethod(other):
                return (self.func.im_class == other.im_class and
                        self.func.im_func == other.im_func)
            else:
                return self.func == other

        elif is_staticmethod(other):
            return self.func == other.__func__

        # other is neither a Primitive nor a callable
        else:
            return False
    def __eq__(self, other):
        """ Two Primitives are equal iff their all their properties are equal.
        Consider bound and unbound methods equal. """
        # other is a Primitive
        if isinstance(other, Primitive):
            return (self == other.func and
                    self.return_type == other.return_type and
                    self.arg_descs == other.arg_descs and
                    self.kwarg_descs == other.kwarg_descs and
                    self.call_afterwards == other.call_afterwards and
                    self.export_me == other.export_me)

        # other is a callable
        elif callable(other):
            if is_instancemethod(self.func) != is_instancemethod(other):
                return False
            elif is_instancemethod(self.func):  # and is_instancemethod(other):
                return (self.func.im_class == other.im_class and
                        self.func.im_func == other.im_func)
            else:
                return self.func == other

        elif is_staticmethod(other):
            return self.func == other.__func__

        # other is neither a Primitive nor a callable
        else:
            return False
Exemplo n.º 3
0
 def _wants(self, theClass):
     return is_instancemethod(self.func) and self.func.im_class == theClass
Exemplo n.º 4
0
 def wants_nothing(self):
     """Does this Primitive want nothing as its first argument? I.e. does
     it want to be passed all the arguments of the block and
     nothing else?"""
     return not is_instancemethod(self.func)
 def _wants(self, theClass):
     return is_instancemethod(self.func) and self.func.im_class == theClass
 def wants_nothing(self):
     """Does this Primitive want nothing as its first argument? I.e. does
     it want to be passed all the arguments of the block and
     nothing else?"""
     return not is_instancemethod(self.func)