Open acatton opened 9 years ago
I'm going to make two silly suggestions:
run('echo', 'header') & run('cat', 'file')
# also
from operator import and_
and_(run('echo', 'header'), run('cat', 'file'))
run('echo', 'header') and run('echo', 'header')
@rockymeza thank you for your suggestion. This issue has been brought up in another thread, and here's my answer.
Oh and BTW, and
can't be overridden in Python.
and
doesn't have to be overwritten, and
just evaluates if a value is Truthy.
class ReturnValue(object):
def __init__(self, code, output):
self.code = code
# ...
def __bool__(self):
return self.code == 0
let me redo my example code since I read the source:
class Subprocess(object):
# ...
def __bool__(self):
self.wait()
return self.returncode == 0
The point of and isn't for short-circuit evaluation, but to compose a new 'command' object that outputs the concatenation of two commands' outputs, to use in a pipeline.
On Wed, Jul 15, 2015 at 11:09 PM, Rocky Meza notifications@github.com wrote:
let me redo my example code since I read the source:
class Subprocess(object):
...
def **bool**(self): self.wait() return self.returncode == 0
— Reply to this email directly or view it on GitHub https://github.com/acatton/python-spm/issues/7#issuecomment-121831116.
oh ok, that's fair
-rocky
On Fri, Jul 17, 2015 at 12:19 AM, Gavin Wahl notifications@github.com wrote:
The point of and isn't for short-circuit evaluation, but to compose a new 'command' object that outputs the concatenation of two commands' outputs, to use in a pipeline.
On Wed, Jul 15, 2015 at 11:09 PM, Rocky Meza notifications@github.com wrote:
let me redo my example code since I read the source:
class Subprocess(object):
...
def bool(self): self.wait() return self.returncode == 0
— Reply to this email directly or view it on GitHub https://github.com/acatton/python-spm/issues/7#issuecomment-121831116.
— Reply to this email directly or view it on GitHub https://github.com/acatton/python-spm/issues/7#issuecomment-122008874.
I would like an API like this: