I'm trying to define standard conventions for naming methods in our wxPython apps, but I'm torn because my code seems to encounter many conflicting "standards":
- wxPython apps tend to use CapitalizedCamelCase a lot.
- PEP 8 advocates using lower_case_with_underscores.
- Yet the Python standard library itself often fails to follow that recommendation, using lowercaseadjoined instead (e.g. splitlines, startswith, joinfields, setdefault, iteritems, and so on).
So it seems that no matter what I choose, our code is going to be a mishmash of conventions due to the related stuff we have to call. What's a poor Pythoneer to do?
I know there's no "right" answer to this question, but as I'm stuck on the fence, I'll appreciate any nudges you care to provide.
Thanks,
- Joe
Pick something and be consistent. If you're working with others, be sure that you all follow the same convention.
When we started Dabo, Paul and I established the conventions that help us maintain the code, and also help newcomers to the framework follow along quicker. It isn't exactly the same as any other standard, but it works for us, and as a result it's hard to look at code from several years ago and figure out which one of us wrote it!
-- Ed Leafe
···
On Dec 5, 2008, at 2:34 PM, Joe Strout wrote:
So it seems that no matter what I choose, our code is going to be a mishmash of conventions due to the related stuff we have to call. What's a poor Pythoneer to do?
I know there's no "right" answer to this question, but as I'm stuck on the fence, I'll appreciate any nudges you care to provide.
Personally, I generally go with StudlyCaps, because I find it the most readable and writable.
However, I've seen some folks advocating a different standard than wx for wxPython code like smallThenCap -- the advantage here is that you always know what's your code and what's wx code. I know I've overwritten a wx method or two by accident, and this would have prevented that.
So, in short, pick a standard you like for your code, and it may in fact be helpful if it doesn't match either the wx standard or the python standard, so it's clear whose code is whose.
-Chris
···
On Dec 5, 2008, at 2:34 PM, Joe Strout wrote:
So it seems that no matter what I choose, our code is going to be a mishmash of conventions due to the related stuff we have to call. What's a poor Pythoneer to do?
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov