I am trying to use a .txt file written by a function in another function which accepts an os.path-like object. My problem is when I feed the argument it shows me the error message
TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper
The following is the simple form of what I am trying to do.
def myfunction1(infile, outfile):
with open(infile, 'r') as firstfile:
#do stuff
with open(outfile, 'w+') as secondfile:
secondfile.write(stuff)
return(outfile)
def myfucntion2(infile, outfile):
infile=myfunction1(infile, outfile)
with open(infile, 'r') as input:
#do stuff
with open (outfile, 'w+') as outfile2:
outfile2.write(stuff)
return(outfile)
Both functions do stuff fine on their own, it's just that I can't seem to feed 2nd function a value from the first.
open(infile)notopen('infile') inmyfunction1`.2ndfile? That's not a valid variable name. How does that run at all to give you that TypeError?