dsmultimedika's picture
Update Repository
0743bb0
raw
history blame
651 Bytes
from uuid import uuid4
def pipe(data, *funcs):
""" Pipe a value through a sequence of functions
I.e. ``pipe(data, f, g, h)`` is equivalent to ``h(g(f(data)))``
We think of the value as progressing through a pipe of several
transformations, much like pipes in UNIX
``$ cat data | f | g | h``
>>> double = lambda i: 2 * i
>>> pipe(3, double, str)
'6'
See Also:
compose
thread_first
thread_last
"""
for func in funcs:
data = func(data)
return data
def generate_uuid(use_hex=False):
if use_hex:
return str(uuid4().hex)
else:
return str(uuid4())