I have
Following piece of code:
for src_filename, src_code in src_dict.iteritems():
try:
set.dependencies = subprocess.check_output('unifdef -s /home/c/maindir/folder/' +src_filename, shell=True)
except subprocess.CalledProcessError, e:
print "code is bad" +set.property
set.bad = 1
raise
set.dependencies = list(set(set.dependencies.splitlines()))
I wanted to un-hardcode the path
so I wrote following piece of code:
filepath = os.path.join(maindirpath, "folder/")
maindir is argument here: /home/c/maindir
path = open(filepath)
set.dependencies = subprocess.check_output("unifdef" '-s' path +src_filename, shell=True)
It throws following error:
TypeError: cannot concatenate 'str' and 'file' objects
I am new to python. can anybody help, where I am getting wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…