Good programming style
grante at visi.com
Mon Sep 15 04:10:14 CEST 2008
On 2008-09-15, Ben Finney <bignose+hates-spam at benfinney.id.au> wrote:
> Grant Edwards <grante at visi.com> writes:
>> On 2008-09-14, Ben Finney <bignose+hates-spam at benfinney.id.au> wrote:
>>> Second: please do yourself a favour and drop the
>>> camelCaseNames. Follow PEP 8
>>> <URL:http://www.python.org/dev/peps/pep-0008> for style and
>>> naming in your Python code.
>> If he finds camelcase more readable and easier to type (as do
>> I), how is switching to underscores "doing himself a favor"?
>> I'm generally in favor of using a consistent naming style
>> throughout a project, but I don't see why the naming style
>> used in my source code should be subject to somebody else's
>> arbitrary standard.
> Because the code we write rarely stays isolated from other
> code. There is an existing convention,
There are many existing conventions.
> and it's better to pick a (sufficiently sane) style convention
> and stick to it than argue about what the convention should
I suppose if everybody agreed to pick one, and all the source
code in the world was changed to meet it, that would "a good
thing". It just seems like a goal so unrealistic as to make it
a bit of an overstatement to tell people they're better off
following convention X than following convention Y.
When packages as significant as wxPython use naming conventions
other than PEP 8, I find it hard to make a case that the PEP 8
naming convention is any better than any other.
>> When it comes to writing code intended for the standard
>> library in the main Python distribution, I would certainly
>> defer to the existing standard as defined in PEP 8. However,
>> I don't see any reason that style should be imposed on all
>> everybody else.
> Who's imposing? I'm saying it's a good idea for everyone to do
> it, and going so far as to say that one is doing oneself a
> favour by following the convention. I have no more power than
> you to "impose" convention on anyone.
My apologies -- "impose" was too strong a word to use.
If we were starting from scratch and there was no extant source
code in the world, then it would make sense to encourage
everybody to pick one convention. [I still think it would be
rather quixotic.] But, there are so many projects out there
with naming conventions other than PEP 8, that I don't see how
there's an advantage to picking one over another (except for
the obvious also-rans like "all upper case, no vowels, and a
maximum length of 6 characters").
I'll agree that sticking with a single convention within a
project is definitely a good thing.
I'm personally aware of mixed/camel-case projects from 25+
years ago, so I'm afraid PEP 8 came along a bit too late...
More information about the Python-list