amitt001 / delegator.py

Subprocesses for Humans 2.0.
MIT License
1.7k stars 92 forks source link

what is the difference for capturing "dir" and "python -V" commands? #31

Closed epogrebnyak closed 7 years ago

epogrebnyak commented 7 years ago

I'm expermenting with delegator.py on Windows, trying to capture process output (whatever was printed to console).

Apparently, I can capture output of a console command, like this:

import delegator
c = delegator.run('dir c:') 
assert c.out.startswith(' Volume in drive C is')

However, when trying to capture output of python -V command, I get empty string while somehting like 'Python 3.6.0' is expected:

d = delegator.run('python -V') 
# expected 'Python 3.6.0'
assert d.out == ''
kennethreitz commented 7 years ago

Python is printing that to standard error, i believe.

epogrebnyak commented 7 years ago

Indeed - this thing passes well:

d = delegator.run('python -V') 
assert d.err.startswith('Python')

Thank you!