Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a context manager into Pipeable objects #2

Open
sbordeyne opened this issue Jan 29, 2020 · 1 comment
Open

Implement a context manager into Pipeable objects #2

sbordeyne opened this issue Jan 29, 2020 · 1 comment

Comments

@sbordeyne
Copy link

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
@agritheory
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants