Planet London Python

July 04, 2009

Simon Brunning

July 03, 2009

Menno Smits

Banishing trailing whitespace with Emacs

One of my pet peeves, especially with Python code, is trailing whitespace. It serves no purpose, introduces noise in diffs and wastes valuable bytes dammit (yes I'm being pedantic).

In order to see make trailing whitespace visible in Emacs you can use the show-trailing-whitespace variable. Emacs of course has a command to remove trailing whitespace: delete-trailing-whitespace.

Better yet, to get rid of trailing whitespace automatically on save you can add a function to the write-contents hook. The following snippet will cause trailing whitespace to be removed on save, but just for Python files.

;; Automatically remove trailing whitespace when saving Python file
(add-hook 'python-mode-hook
          (lambda () (add-hook 'write-contents-hooks 'delete-trailing-whitespace t)))

The one problem with doing this is that when changing an existing codebase your commits could end up with many whitespace deltas, making it difficult to see the meat of your changes. Use with care.

July 03, 2009 11:06 AM

July 02, 2009

Sam Newman

Fuzzyman

Open Source Licensing and Contributions

There have been discussions on the issues of licensing and accepting contributions to open source projects on the Python-dev and the testing in Python mailing lists. This is an area that can be very confusing, and potentially problematic for open source projects. ... [376 words]

July 02, 2009 03:59 PM

Sam Newman

Is #mongodb too good to be true? Where’s the catch? Ah - their website is powered by...

Is #mongodb too good to be true? Where’s the catch? Ah - their website is powered by Confluence…

July 02, 2009 08:27 AM

July 01, 2009

Sam Newman

Just watched: #Yellowstone on BBC4. Simply stunning - rivals Planet Earth for beauty. No idea why...

Just watched: #Yellowstone on BBC4. Simply stunning - rivals Planet Earth for beauty. No idea why it’s hidden on BBC4…

July 01, 2009 09:12 PM

Now reading: Agile Estimation and Planning by Mike Cohn. Off to a dry start - I hope it picks...

Now reading: Agile Estimation and Planning by Mike Cohn. Off to a dry start - I hope it picks up…

July 01, 2009 06:48 PM

Just read: #D-Day by Antony Beevor. By turns harrowing, entertaining and insightful. Recommended.

Just read: #D-Day by Antony Beevor. By turns harrowing, entertaining and insightful. Recommended.

July 01, 2009 06:48 PM

Just won on ebay: Nikon FM3a. Might have to freeze myself and get a friend to thaw me out for its...

Just won on ebay: Nikon FM3a. Might have to freeze myself and get a friend to thaw me out for its arrival date. Flawless plan.

July 01, 2009 06:48 PM

Fuzzyman

Exception handling and duck typing

Exceptions are one of the great features of high level languages that making coding less tedious. Instead of manually checking for possible errors and returning error codes we can use exceptions. ... [675 words]

July 01, 2009 05:50 PM

June 29, 2009

Simon Brunning