Skip to content

Commit

Permalink
Merge argh
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens committed Nov 20, 2024
1 parent 439a36e commit 59f3353
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions kurbopy/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,9 @@ def do_magic(self, rhs, methodname):
raise TypeError("Cannot %s %s by %s" % (methodname, mytype, other_type))


<<<<<<< HEAD
for method in ["mul", "add", "sub", "isub", "iadd"]:
magic = functools.partial(do_magic, methodname=method)
magic.__name__ = method
magic.__doc__ = "Magic method " + method
globals()["magic_" + method] = magic
=======
def magic_sub(self, rhs):
other_type = get_magic_name(rhs)
mytype = get_magic_name(self)
if hasattr(self, "_sub_" + other_type):
return getattr(self, "_sub_" + other_type)(rhs)
raise TypeError("Cannot subtract %s from %s" % (other_type, mytype))


def magic_isub(self, rhs):
other_type = get_magic_name(rhs)
mytype = get_magic_name(self)
if hasattr(self, "_isub_" + other_type):
return getattr(self, "_isub_" + other_type)(rhs)
raise TypeError("Cannot subtract %s from %s" % (other_type, mytype))


def magic_add(self, rhs):
other_type = get_magic_name(rhs)
mytype = get_magic_name(self)
if hasattr(self, "_add_" + other_type):
return getattr(self, "_add_" + other_type)(rhs)
raise TypeError("Cannot add %s to %s" % (other_type, mytype))


def magic_iadd(self, rhs):
other_type = get_magic_name(rhs)
mytype = get_magic_name(self)
if hasattr(self, "_iadd_" + other_type):
return getattr(self, "_iadd_" + other_type)(rhs)
raise TypeError("Cannot add %s to %s" % (other_type, mytype))
>>>>>>> 729889f (Fix up magic operators)

0 comments on commit 59f3353

Please sign in to comment.