This repository was archived by the owner on Apr 24, 2018. It is now read-only.
This repository was archived by the owner on Apr 24, 2018. It is now read-only.
Idea: Use __or__ for chaining #2
Open
Description
For the common case linking stdout to stdin of another process, we could use the 'pipe' syntax from shells by overloading the __or__
method.
Part of me thinks this is way too clever (in a bad way)... the other half thinks this would be really awesome/elegant.
Just an example:
class PipeCommand(object):
def __init__(self, cmd):
self.cmd = cmd
def __repr__(self):
return self.cmd
def __or__(self, other):
return PipeCommand('|'.join([self.cmd, other.cmd]))
def run(cmd):
return PipeCommand(cmd)
print run('cat') | run('wc -l')
Metadata
Metadata
Assignees
Labels
No labels