0

New to Python and coding in general. The more I learn (from different sources), the more I continue to hear the phrase "...this is a common naming convention." With the desire to do it right the first time, I wondered if there was a repository or central location for most/many of the common naming conventions found in Python. To clarify, I mean using "self" as the first parameter of a Class, importing numpy as np, importing pyplot as plt, importing pandas as pd, etc...

I have searched PEP 8 and SO and Google (and Google's style guide as suggested by an answer) and have not found anything like this. Is it worthwhile to have a resource such as this? If not, why?

I am considering this both as a student new to coding but also as an experienced (former) manager who has had to write many SOPs and understands the value of a repository for common information.

EDIT: I am appending further clarification: "given self as a convention when creating a class, what are other conventions that are commonly reserved words a beginner might not know?"

Thank you,

2 Answers2

3

This is Google style guide. Pretty useful.

As you state, you already know the importance of having good variable naming convention and practice throughout the company.

Although this is followed by Google, but the rules there are decent and useful and can be followed by team where lot of hands are on same code base.

lllrnr101
  • 2,288
  • 2
  • 4
  • 15
  • 1
    Pretty useful and generalist. This "style" is actually compatible with many other languages. E.g. [K&R](https://en.wikipedia.org/wiki/Indentation_style#K&R_style)'s. – keepAlive Feb 12 '21 at 15:33
  • I have updated the question but I also wanted to thank you for your input. I have reviewed the entire Google style guide and I do see its utility. However, it does not exactly answer my question. Figuring it may be how I worded my question, I have rephrased to: "given 'self' as a convention when creating a class, what are other conventions that are commonly reserved words a beginner might not know?" – Mark Raiman Feb 16 '21 at 15:06
1

There are various naming conventions across many different languages, and styles of writing code. For example in javascript there are many style guides, code is subjective and even companies like big companies like AirBnb have released their own "style-guide" which many companies copy.

A good place to look if you can't find it in the docs, would be popular python packages, scipy, matplotlib, numpy etc...

Here is the naming conventions part in the docs: https://www.python.org/dev/peps/pep-0008/#naming-conventions

In python most people agree on "naming_like_this" except for classes and such like.

Whereas in JavaScript people normally use camelCase "namingLikeThis".

The important thing is to be consistent across each code base and more importantly is naming things usefully rather than concentrating on the style of writing things.

mortuie
  • 325
  • 3
  • 11