Linked by pkrumins on Thu 19th Feb 2009 12:17 UTC
General Development If you have ever been interested in awk and sed Unix utilities, then you probably know about the awk1line.txt and sed1line.txt files that are floating around the Internet. Each file contains around 80 idiomatic sed and awk one-liners for performing various text modification tasks.
Thread beginning with comment 350087
To view parent comment, click here.
To read all comments associated with this story, please click here.
Member since:

It's neither. It should be: with file("file.txt") as fd:

Such pedantic diligence ('with' statement) is probably not appropriate in a thread that mentions awk/sed. Using with statement is needed when you are worrying about closing file handles in some-future-version-of-python that may not do reference counting (which could imply that the file handle would remain open until the next garbage collection cycle).

Not really something you need to worry about if you are mainly targeting your normal python installation. Furthermore, a linear script can just close() the filehandle without caring about exceptions (because it would just exit the process and close everything anyway).

Reply Parent Score: 1