My question is related to file-input in Python, using open(). I have a text file mytext.txt with 3 lines. I am trying to do two things with this fi
open()
mytext.txt
I thin the module fileinput is you want.
Here is the link
if __name__ == "__main__": for line in fileinput.input(): if fileinput.isfirstline(): print("current file: %s" % fileinput.filename()) print("line number: %d, current file number: %d" % (fileinput.lineno(), fileinput.filelineno()))