So im trying to save the output from my subprocess.call but I keep getting the following error:
AttributeError: 'int' object has no attribute 'communicate'
Code is as follows:
p2 = subprocess.call(['./test.out', 'new_file.mfj', 'delete1.out'], stdout = PIPE)
output = p2.communicate[0]
Popenwere basically correct in 2012 when this question was asked, but the modern correct answer is to usesubprocess.run, orsubprocess.check_outputif you need a simple API and/or compatibility back to older Python versions. Thesubprocessdocumentation spells this out, in the very first paragraph of the first section; "The recommended approach to invoking subprocesses is to use therun()function for all use cases it can handle."