One Code Styleguide Per Programming Language Is Not Silly
I love Python but there are things where I look at Ruby or Java and want to switch right away. What do have Ruby and Java in common? Nearly all of their libraries follow the same function/method/class naming conventions. foo_bar_baz in Ruby and fooBarBaz in Java. In Python there we have that PEP8 thing, but not even the standard library is PEP8 compatible. Many people tell me that not having the same naming guidelines for all libraries is a problem. I would argue that different naming guidelines among different libraries is a bigger problem than different indentation etc.
The reason for that is that in Python we often subclass clases from other libraries. Just take the threading module as example. Now we are forced to use different names in your own libraries/code too. Now one has to start thinking about the names of methods. (Is is get_some_foo() or some_foo or getSomeFoo()). It becomes even worse if you use mixin classes with one styleguide in a subclass of a class with a different one. I’ve seen people using the `DictMixin` in classes with camel case method names. But even the lowercase names are not coherent. Is it iteritems or iter_items? This example might be answered easily because I never saw iter_items but I saw countless occurrences of both getcurrentuser and get_current_user.
The more different name styles in a code the more I have to use dir(), help(), external documentation or the ipython source introspection. And that’s not the fault of the library developers, it starts with the python language itself. The internal types are all lowercase although they are classes. It’s true that this is because of backwards compatibility (when dict, list and others were just functions) but a big language change like Python3 would have made changing some of those names possible.
</rant>
The biggest problem is that PEP 8 was not around when a bunch of stuff went into the stdlib (it didn’t come until being until July 2001 which is over 11.5 years after Python’s creation). While the module names will get fixed in Python 3.0, changing method and functions are harder as those can’t be automated.
Hopefully we can, at some point, either rename methods and function slowly, or just replace/remove old modules.
Comment by Brett — Sunday, November 4th, 2007 @ 9:50 pmFully agreed. The names in the stdlib suck, and it sucks even more that many people and libraries don’t adapt the PEP 8 style.
Comment by mq — Saturday, November 10th, 2007 @ 6:06 pm