[Pyparsing] PEP-8 compliant naming, using synonyms
Brought to you by:
ptmcg
From: Paul M. <pt...@au...> - 2008-03-07 14:34:44
|
A while back, there was a suggestion to adopt PEP-8 compliant names in pyparsing. For example, oneOf, delimitedList, and quotedString do not conform to the PEP-8 recommended naming style. According to PEP-8, these should be one_of, delimited_list, and quoted_string. For this discussion, I'll call these two naming styles "mixedCase" and "names_with_underscores". I've used names_with_underscores for many years, in Pascal, PL/1, and C. When I learned Smalltalk, Java and C++, the general convention was shifting (to my perception anyway) to mixedCase naming. When I learned Tcl for my job, names_with_underscores was again prevalent, and I eventually came to equate mixedCase with "new and fun" and names_with_underscores with "archaic and nasty." So when I was developing pyparsing, I read PEP-8. I was still fairly new to Python, and had not fully navigated the waters of what's new and what's old. Everything that's ever been done in Python is documented *somewhere*, and very few places guide you that "module X is outmoded/deprecated" or "module Z is the new module Y". So I just assumed that PEP-8 was a product of its own generation (as are we all), and reflected late-80's/early-90's thinking, and that things had evolved some since the PEP's initial writing. Wanting to write code for the 21st century, I used mixedCase for pyparsing. Since then, I've gotten a few isolated feedback comments that pyparsing is nonstandard because it does not use names_with_underscores as directed in PEP-8. Of course, as any politician will tell you, the feedback you actually get is usually representative of many more with the same opinion, who for whatever reason choose not to express it aloud. Unfortunately, much of this discussion hinges on personal taste, so objective discussion is usually contrived, or constructed by someone who is trying to rationalize their existing preference (very similar to some of the "justifications" for different bracing styles when trying to establish a C/C++ or Java coding standard). I did receive one actual, objective, practical distinction between the two naming styles from one user who is vision impaired - on his tactile- and audio-assist hardware, it is difficult to change case within a contiguous word, but quite easy to insert an underscore, so pyparsing's use of mixedCase really slows him down. So I've considered adding PEP-8 compliant synonym definitions to pyparsing. This would consist of a series of name bindings added to pyparsing that look like: one_of = oneOf quoted_string = quotedString delimited_list = delimitedList rest_of_line = restOfLine Existing names would not be deprecated unless there was some huge "hurrah!" from the Python world. But I know that many people are already using the mixedCase style, and I strongly believe in not breaking peoples' existing code. Class names would not require synonyms, as ClassNameStyle as used in pyparsing *is* PEP-8 compliant, so OneOrMore, ZeroOrMore, etc. would not need to be changed or synonymified. Any comments? Thanks, -- Paul |