Question

I'm planning to start a project (a TCP server) using Twisted. I know Twisted uses camelCase for naming functions. The PEP8 says we should use lower_case_with_underscores. I know that the PEP8 was written after the Twisted coding standards, so they're not going to change a lot of code with the camelCase convention. There's just one thing that makes me doubt. Check out this quote from here.

If you're making a new Python project today, unless it is intended specifically
as extension for Twisted, you should ignore the relative merits of these coding standards and go with PEP 8, because the benefits of consistency generally outweigh any particular benefits of one coding standard or another.

So how can I achieve consistency in my project if my code will use the PEP naming convention and the main framework that is going to take the 50 or 60 percent of my code uses camelCase?

Thanks in advance.

Was it helpful?

Solution

Quote from PEP 8 -

When in doubt, use your best judgment. Look at other examples and decide what looks best.

This boils down to you i.e. the current project. It is actually a matter of personal choice. The PEP 8 or any other styleguide is basically, a guide. You'll have to judge as to what goes better with your situation.

Specific points that would matter, which I would like to mention are -

  1. Do you have a lot a acronyms that would be used?
  2. What is your project team comfortable with?

And, like I mentioned in my comment, using lower_case_with_underscores helps differentiate Twisted modules & your custom modules/functions.

OTHER TIPS

It's really up to you. Use your best judgement, whatever makes you and your team comfortable.

Except for the fact that camelCase is objectively superior in every conceivable way, of course, and Python made a wrong turn at standardizing on underscores ;-).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top