You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Python object-oriented programming (OOP), the capitalization convention is guided by the PEP 8 style guide, which is widely accepted in the Python community. Here's how it recommends capitalizing different types of objects:
Class Names: Class names should normally use the CapWords convention, where each word in the name starts with a capital letter and the rest of the letters are lowercase. This is also known as CamelCase. Example: MyClassName.
Function and Method Names: Functions and method names should be lowercase, with words separated by underscores to improve readability. Example: my_function or my_method.
Variable Names: Variable names should also be lowercase with words separated by underscores. Example: my_variable.
Constants: Constants used in a global scope should be capitalized, with words separated by underscores. Example: MY_CONSTANT.
Module and Package Names: Modules and package names should have short, all-lowercase names, possibly with underscores. Example: mymodule, my_package.
Instance Variables: They follow the same convention as function and variable names (lowercase with underscores). Example: my_instance_variable.
Private and "Special" Methods: Private methods or variables (meant for internal use) typically start with a single underscore, while special or "magic" methods that are part of the Python data model start and end with double underscores. Example: _private_method, __init__.
Remember, these conventions are guidelines to ensure code readability and consistency across Python projects. They're not enforced by the Python interpreter, but adhering to them can make your code more maintainable and easily understood by other Python developers.
For our repository:
Let's make all the folder names lower case with underscores (a.k.a. snake_case) e.g., whobpyt/models/robinson_time
For the .py files inside the folders, each word is capitalized with no underscore (a.k.a. CamelCase) e.g., whobpyt/models/robinson_time/ParamsRobinson.py
The classes inside the .py file are also CamelCase (e.g., ParamsCT, so it looks like this when importing: from whobpyt.models.robinson_time.ParamsRobinson import ParamsCT.
The methods & functions inside the .py file are all snake_case. e.g., forward() or add_dimension().
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
General introduction, per ChatGPT:
For our repository:
whobpyt/models/robinson_time.pyfiles inside the folders, each word is capitalized with no underscore (a.k.a. CamelCase) e.g.,whobpyt/models/robinson_time/ParamsRobinson.py.pyfile are also CamelCase (e.g.,ParamsCT, so it looks like this when importing:from whobpyt.models.robinson_time.ParamsRobinson import ParamsCT..pyfile are all snake_case. e.g.,forward()oradd_dimension().Beta Was this translation helpful? Give feedback.
All reactions