4 ms·
for line in f: is multiple mistakes in a single line.
by yifanl 2y ago
for line in f:
is multiple mistakes in a single line.
- falcor84 2y agoWhat are the mistakes there?
- galbar 2y agoThe most obvious one: with open(self.file_path, 'r') as openFile: for line in f: `f` does not exist. It should be `openFile`.
- dpassens 2y agoOne is that the variable is called openFile and not f. I don't know enough python to see something else wrong with that but would love to know too, since I've written such a line just last week.
- yifanl 2y agof doesn't refer to anything. iterating over the file object at all instead of just calling self.cache = openFile.readlines() means that calling strip() the line below removes data beyond just the trailing newlines.