Learn the Python standard library

By muharem

One of the big benefits of making code available publicly is the feedback received. Sometimes, the feedback points to python standard library modules I was unaware of.

A case in point is a post on Linux Questions in which the author is pointing out the fileinput module.

Python indeed comes with the batteries included :-)

I will have a more thorough look at the fileinput module and probably refactor the scriptutil.freplace() function (described here) to make use of it.

2 Responses to “Learn the Python standard library”

  1. Mike Says:

    Muharem,

    Nice work with the scriptutil module — I find it very useful. One feature I’d like to see is the ability to retrieve line numbers from ffindgrep() a la “grep -n”.

    I was going to hack this in myself, but if you’re going to refactor with the fileinput module, this might be an easy extension with fileinput.filelineno()

    Thanks!

  2. muharem Says:

    Hello Mike,

    thanks for your kind comments. Adding line numbers to ffindgrep() output looks reasonably straightforward. I should probably have something tomorrow. Stay tuned :-)

Leave a Reply