Python’s “with” keyword

Python recently introduced the “with” keyword. It is another way of automatically cleaning up something at the end of a block. It is a way to try and get some of the destructor functionality of C++ into a garbage collected language. Garbage collection, IMHO, continues to be a mixed blessing and I think the “with” keyword is an ugly (but useful) way to deal with one of its shortcomings.

This entry was posted in Programming. Bookmark the permalink.