The last two posts looked at Python list comprehensions. [See Simple Tricks #2 and Simple Tricks #3] This time we look at file handling, one of the most common tasks programmers deal with, especially with script languages such as Python.
Python’s native file object, created with the built in open function, is simple and easy, but here are some tricks that make file access even simpler and easier.