pipey
pipey copied to clipboard
Implement a context manager into Pipeable objects
A context manager implementation would be useful in my opinion, in some cases.
from pipey import Pipeable
with ([1, 2, 3] >> Array >> Vectorize) as vector:
# Do stuff with vector, which contains a Pipeable with the result of the above expression
Another way to to leverage context managers that might be useful:
with Pipeable(print) as print:
[1, 2, 3] >> Array >> print
print("print normally in normal context")
This would allow you to temporarily/ contextually move something into a Pipeable context and return it to its normal functionality afterwards. This is a "I only need to do this once" flavor solution, where if you were using print
multiple times as a Pipeable, you'd just declare it as such.