Archive for April, 2012

PEP8 it is, then

Thanks to everyone who commented on my previous PEP8-related posts. It’s been quite an eye-opener for me to see how many people felt strongly that PEP8-compliance was a real must-have, not just for core Python itself but for any Python project. My own use of Python just about predates PEP8 itself, and certainly predates its more widespread adoption within the community. And, while I was aware that it was a default recommendation for someone seeking style guidelines, I don’t think I’d appreciated just how wide and strong its uptake was.

Of the comments made to my previous posts, only one outright dismissed PEP8; several spoke neutrally, more or less echoing the sentiments I’d expressed; but the majority which expressed a clear opinion made it strongly advisable, not to say mandatory, to follow PEP8 for one’s own (published) work.

So I’ve decided to switch to near-PEP8 style. (Note that pretty much everyone and every project varies a little, most commonly on the line length issue). The two key points which seemed — startlingly, from my perspective — to bother people the most were the two-space indents and the space-before-brackets. If you cared to peruse my winshell & active_directory github repos, you’ll note that those are now in line with PEP8. Others will follow as and when.

You’re probably not surprised to hear me say that, having made the switch, I can’t understand how anyone can prefer the PEP8 style. If I’ve switched, it’s not because I’ve had a sudden aesthetic revelation which makes me wonder why I wasn’t using 4-space indents all along. Quite the reverse: for the life of me I can’t see why anyone would prefer it. Rather, it’s because I recognise the value of a commonly-held standard within a community. And because, when I weighed it up, there was no reason — beyond my own preferences — not to switch.

I’ve tweaked my SciTE options and added the PEP8 module to my test scripts, turning off certain of the checks and allowing for slightly longer lines. Let’s see what I feel about this in a month or so’s time.