> Here's what I knocked up over lunch. It doesn't cover the moving of > the file, I don't like that it's deep-nested, and I've not tested it, > but I welcome criticism and feedback: > > files = ['file1', 'file2', 'file3', 'file4'] > settings = ['export http_proxy=', 'ftp_proxy='] > > for file in files: > with open(file, 'rw') as file: >
Does this actually work? I didn't think you could open files as reading and writing? also you're shadowing the 'file' var, which might be confusing to beginners, as it's not the same file as in the outer for loop. Also, 'with' is a 3.0 keyword, right? That's pretty interesting syntax, I've never seen it before, but I haven't used 3.x yet. > for line in file: > for setting in settings: > if setting in line: > if line[0] == '#': > line = line[1:] > else: > line = '#' + line > output.write(line) > Also, you didn't define 'output' anywhere. Is this an implicit declaration via the 'with' syntax? Thanks, -Luke > > S. > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor