I am using the following call for executing the ‘aspell’ command on some strings in Python:
r,w,e = popen2.popen3("echo " +str(m[i]) + " | aspell -l")
I want to test the success of the function looking at the stdout File Object r. If there is no output the command is successful.
What is the best way to test that in Python?
Thanks in advance.
Best is to use the
subprocessmodule of the standard Python library, see here —popen2is old and not recommended.Anyway, in your code,
if r.read(1):is a fast way to test if there’s any content inr(if you don’t care about what that content might specifically be).