What is the most used convention for naming variables in Python / Django? ex: pub_date or pubdate
What about for classes and methods?
The choice of a variable name should be mnemonic — that is, designed to indicate to the casual observer the intent of its use. One-character variable names should be avoided except for temporary "throwaway" variables. Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters.
A variable name must start with a letter or an underscore character (_) A variable name cannot start with a digit. A variable name can only contain alpha-numeric characters and underscores ( a-z, A-Z , 0-9 , and _ ) Variable names are case-sensitive (age, Age and AGE are three different variables)
Django's coding style
PEP 8, nothing more to say.
Of course you can use your own style (I use camelCase, for example), but most people use recommendations from that PEP.
Code Complete (http://www.cc2e.com/) has some great chapters about function/variable naming, not for Python explicitly, but perhaps still interesting...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With