I have a current implementation like this:
class Infix(object):
def __init__(self, func):
self.func = func
def __or__(self, other):
return self.func(other)
def __ror__(self, other):
return Infix(partial(self.func, other))
def __call__(self, v1, v2):
return self.func(v1, v2)
@Infix
def Map(data, func):
return list(map(func,data))
This is great, it works as expected, however I want to also expand this implementation to allow for a left side only solution. If somebody can showcase a solution AND explanation, that would be phenomenal.
Here is an example of what I would like to do...
valLabels['annotations'] \
|Map| (lambda x: x['category_id']) \
|Unique|
Where Unique is defined as below...
@Infix
def Unique(data):
return set(data)
Thanks!
|.