def __new__(cls, iterable): items = builtins.tuple(iterable) try: cls.mtypes except AttributeError: cls = cls[builtins.tuple(map(type, items))] return builtins.tuple.__new__(cls, items) assert (len(cls.mtypes) == len(items)) items = (mtype(item) for mtype, item in zip(cls.mtypes, items)) return builtins.tuple.__new__(cls, items)
def __new__(cls, iterable): items = builtins.tuple(iterable) try: cls.mtypes except AttributeError: cls = cls[builtins.tuple(map(type, items))] return builtins.tuple.__new__(cls, items) assert(len(cls.mtypes) == len(items)) items = (mtype(item) for mtype, item in zip(cls.mtypes, items)) return builtins.tuple.__new__(cls, items)
def __getitem__(cls, mtypes, typedcls=None): if not typedcls: class typedcls(cls): pass typedcls.mtypes = mtypes = builtins.tuple(mtypes) typedcls.__module__ = cls.__module__ typedcls.__name__ = '%s[%s]' % ( cls.__name__, ', '.join(t.__name__ for t in typedcls.mtypes)) return typedcls
def __getitem__(cls, mtypes, typedcls=None): if not typedcls: class typedcls(cls): pass typedcls.mtypes = mtypes = builtins.tuple(mtypes) typedcls.__module__ = cls.__module__ typedcls.__name__ = '%s[%s]' % (cls.__name__, ', '.join( t.__name__ for t in typedcls.mtypes)) return typedcls
return lazy fmemo = flazy # return a closure with the function's arglist partially applied fpartial = functools.partial # return a closure that applies the provided arguments to the function `f`. fapply = lambda f, *a, **k: lambda *ap, **kp: f( *(a + ap), **builtins.dict(k.items() + kp.items())) # return a closure that will use the specified arguments to call the provided function. fcurry = lambda *a, **k: lambda f, *ap, **kp: f( *(a + ap), **builtins.dict(k.items() + kp.items())) # return a closure that applies the initial arglist to the end of function `f`. frpartial = lambda f, *a, **k: lambda *ap, **kp: f( *(ap + builtins.tuple(builtins.reversed(a))), **builtins.dict(k.items() + kp.items())) # return a closure that applies the arglist to function `f` in reverse. freversed = freverse = lambda f, *a, **k: lambda *ap, **kp: f( *builtins.reversed(a + ap), **builtins.dict(k.items() + kp.items())) # return a closure that executes function `f` and includes the caught exception (or None) as the first element in the boxed result. def fcatch(f, *a, **k): def fcatch(*a, **k): try: return builtins.None, f(*a, **k) except: return sys.exc_info()[1], builtins.None return functools.partial(fcatch, *a, **k)
from six.moves import builtins c1 = complex() d1 = dict() f1 = float() i1 = int() l1 = list() s1 = str() t1 = tuple() c2 = builtins.complex() d2 = builtins.dict() f2 = builtins.float() i2 = builtins.int() l2 = builtins.list() s2 = builtins.str() t2 = builtins.tuple()