One of the most often read postings on this blog is the one about my getopts-enabled shell script template. So I figured, a similar template in Python would also be useful. Like the shell script, it’s quite trivial, but it might still save some time.
A Template for Python Unix Utilities
Posted October 24, 2009 by mafrCategories: python
Tags: linux, python, scripting
Quick Tip #3: Creating Histograms in Python
Posted September 10, 2009 by mafrCategories: python
Tags: python, quick tips
Since Python 2.5, creating histograms has become easier. Instead of dict, we can now use defaultdict which is similar in behavior to awk’s associative arrays. Instead of raising a KeyError for undefined keys, defaultdict adds a user-defined item and returns it.
An IMAP Configuration for Mutt
Posted September 8, 2009 by mafrCategories: linux
Tags: linux, shell, tools
Usually, I download all my email via fetchmail, sort it into folders using procmail and read the mails with mutt. This works reasonably well and I’ve been using this mail setup without major changes for about 10 years. Since I recently bought a netbook, I also wanted to read mails with it, but without touching my existing mail setup. The netbook should only read mails directly on the server without downloading anything to local disk.
Ubuntu: Changes in Python 2.6
Posted August 26, 2009 by mafrCategories: linux
Tags: linux, python
Once in a while, I install Python packages from source using distutils. The distutils-powered setup.py script found in many packages installs software in /usr/local/ – quite useful because it doesn’t interfere with packages managed by your distribution. Since Ubuntu Jaunty and Python 2.6, this doesn’t work anymore.
Quick Tip #2: Set Operations Using Shell Tools
Posted August 19, 2009 by mafrCategories: shell
Tags: linux, quick tips, shell, tools
Everybody knows that Unix shell utilities are powerful. Even though they’re text-based, you can build a lot of useful things outside of the text domain. Today I’ll show you how to implement set operations. All we need are sorted files as input, with each file representing a set.
Google Code: Migrating to Mercurial
Posted July 31, 2009 by mafrCategories: tools
Tags: rcs, tools
Although one could have guessed otherwise, I’ve always been a happy Subversion user. Which former CVS user hasn’t? But now I’m ready to take the next step. For some of my personal stuff I’ve been using Mercurial for more than a year, so I thought it was time to take the plunge and switch my JSysTest project to Mercurial.
Subversion 1.5 Merging Massacres
Posted July 25, 2009 by mafrCategories: tools
Tags: opinion, rcs, tools
Recently, I had the opportunity to work with Subversion 1.5 on a medium sized project. Since there were more than 20 developers working on the project with some of them in a different country, there was no other way than to use feature branches extensively. We thought Subversion’s merge tracking would reduce typical merging errors by simplifying the process. But, well, we were wrong.
A Case for Guard Clauses
Posted June 12, 2009 by mafrCategories: best practices
Tags: best practices, opinion, quality
One of my pet peeves in programming is that few people use guard clauses. A guard clause is an almost trivial concept that greatly improves readability. Inside a method, handle your special cases right away and return immediately.