coerce
Overload the __rshift__
operator of obj to call its .next() method and do the same for the object it's called on.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
Nextable |
an object with a |
required |
Returns: obj
Source code in orkestra/utils.py
def coerce(obj: Nextable) -> Nextable:
"""
Overload the `__rshift__` operator of obj to call its .next() method and do the same for the object it's called on.
Args:
obj: an object with a `.next(self, other)` method
Returns: obj
"""
def rshift(self, right):
result = self.next(right)
coerce(right)
coerce(result)
return result
obj.__class__.__rshift__ = rshift
return obj