mirror of
https://github.com/m5stack/M5Stack_MicroPython.git
synced 2026-05-20 10:14:44 -07:00
27 lines
591 B
Python
27 lines
591 B
Python
def partial(func, *args, **kwargs):
|
|||
|
|
def _partial(*more_args, **more_kwargs):
|
||
|
|
kw = kwargs.copy()
|
||
|
|
kw.update(more_kwargs)
|
||
|
|
return func(*(args + more_args), **kw)
|
||
|
|
return _partial
|
||
|
|
|
||
|
|
|
||
|
|
def update_wrapper(wrapper, wrapped):
|
||
|
|
# Dummy impl
|
||
|
|
return wrapper
|
||
|
|
|
||
|
|
|
||
|
|
def wraps(wrapped):
|
||
|
|
# Dummy impl
|
||
|
|
return lambda x: x
|
||
|
|
|
||
|
|
def reduce(function, iterable, initializer=None):
|
||
|
|
it = iter(iterable)
|
||
|
|
if initializer is None:
|
||
|
|
value = next(it)
|
||
|
|
else:
|
||
|
|
value = initializer
|
||
|
|
for element in it:
|
||
|
|
value = function(value, element)
|
||
|
|
return value
|