pipey icon indicating copy to clipboard operation
pipey copied to clipboard

Implement a context manager into Pipeable objects

Open sbordeyne opened this issue 5 years ago • 1 comments

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

sbordeyne avatar Jan 29 '20 23:01 sbordeyne

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.

agritheory avatar Feb 05 '20 16:02 agritheory