0

I have a C++ program which prints some data, but I call the program from my python script (I have performed boost python integration). But now I want to read the data which I have generated, from the same python script, but I just don't know how (new to Python).

I tried some recommendation from stack overflow such as

import subprocess
command = ['ls', '-l']
p = subprocess.Popen(command, stdout=subprocess.PIPE, 
stderr=subprocess.IGNORE)
text = p.stdout.read()
retcode = p.wait()

but the compiler throws an error module 'subprocess' has not attribute 'IGNORE'

Maybe I have compatibility issues with my current version of Python. I use Python 3.6.7 environment installed with Microsoft Visual Studio 2019. Can it be one of the reasons?

The data I need to read looks like this on the command prompt:

sol1=3.14789865446, .............................. (6 float values)
sol2=4.68909927756, .............................. (6 float values)
.
.
.
.
sol7=0.64527278288, .............................. (6 float values)
10
  • 1
    I never heard of subprocess.IGNORE in python? In which version do you actually use that? What exactly do you want to happen? I guess you want to use subprocess.DEVNULL Commented Aug 8, 2019 at 21:18
  • @Mack123456 It was mentioned here stackoverflow.com/questions/8217613/…. I am using this in Python 3.6 Commented Aug 8, 2019 at 21:21
  • @Mack123456 I used DEVNULL as well. I got the error system cannot find the file specified Commented Aug 8, 2019 at 21:22
  • @Mack123456 I just want to read data printed by the python script on the command prompt. I am trying to do that in the same python script. Like the script generates some data and then reads the same data. Commented Aug 8, 2019 at 21:27
  • 1
    There is no subprocess.IGNORE in either Python 2,7 or 3.7.4. Commented Aug 8, 2019 at 22:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.