diff --git a/src/fix.py b/src/fix.py index 9d7c59f86..bc53735c4 100644 --- a/src/fix.py +++ b/src/fix.py @@ -36,11 +36,14 @@ Fixes stuff that Python should have but doesn't. __all__ = [] exported = ['ignore', 'catch', 'reviter', 'window', 'group', - 'partition', 'any', 'all', 'rsplit'] + 'partition', 'any', 'all', 'rsplit', 'curry'] +import new import string string.ascii = string.maketrans('', '') +curry = new.instancemethod + def ignore(*args, **kwargs): """Simply ignore the arguments sent to it.""" pass diff --git a/src/irclib.py b/src/irclib.py index a7fc5e357..cbd5e44db 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -249,7 +249,7 @@ class IrcState(IrcCommandDispatcher): self.nicksToHostmasks = ircutils.IrcDict() def __getstate__(self): - return map(lambda name: getattr(self, name), self.__slots__) + return map(curry(getattr, self), self.__slots__) def __setstate__(self, t): for (name, value) in zip(self.__slots__, t): diff --git a/src/utils.py b/src/utils.py index 43de7d558..cc1eb9790 100755 --- a/src/utils.py +++ b/src/utils.py @@ -235,7 +235,7 @@ def perlReToReplacer(s): flags = filter('g'.__ne__, flags) r = perlReToPythonRe('/'.join(('', regexp, flags))) if g: - return lambda s: r.sub(replace, s) + return curry(r.sub, replace) else: return lambda s: r.sub(replace, s, 1)