I have defined a series of python objects of class dofiles which have a name and some empty lists.
class dofile:
name = ""
lines = []
inputs = []
outputs = []
intermediates = []
I am using the following code to loop through a list of these dofile objects called dofiles (after I have run code which fills up the lines list for each object which I know works correctly). The problematic code detects the phrase using and the word after it, then should append the word to the inputs list for each object.
for dofile in dofiles:
for line in dofile.lines:
# using
using_tups = re.findall(r'(using)\s([^\s,]+)', line)
for tuple in using_tups:
dofile.inputs.append(tuple[1])
However, I am ending up with the word appended to the inputs list of all of the dofile objects in dofiles. (ex: print(dofiles[0].inputs) and print(dofiles[1].inputs) return the same thing although they scan different files).
Am I missing something about how objects, lists, or loops work in Python?
I've tried (dofile.inputs).append(tuple[1]) but it doesn't seem to make a difference.
Thanks.