I think naming an interface with an I prefix is perfectly acceptable.
e.g.:
IFooIPublishable
A few years back I used Zope Interfaces. I noticed most codebases used this convention. Our team did too.
We preferred IFoo vs. FooInterface or IFooInterface
I think naming an interface with an I prefix is perfectly acceptable.
e.g.:
IFooIPublishable
A few years back I used Zope Interfaces. I noticed most codebases used this convention. Our team did too.
We preferred IFoo vs. FooInterface or IFooInterface
I'm not aware of any community-wide standards in that regard apart from PEP8, which doesn't address this specifically.
I'd suggest to do whatever your team is most comfortable with, but above all else be consistent.
coding style - Python file naming convention? - Software Engineering Stack Exchange
What is the naming convention in Python for variables and functions? - Stack Overflow
Naming conventions and good practice? m_, _, _ptr, g_, get(), set()
Would it be sacrilegious to name pure abstract base classes with the 'I' prefix?
Videos
Hey python developers! So, I've hardly written any interfaces or ABC's in python. But, I'm about to build a package which is supposed to act as a base for several teams. I've started writing interfaces, but.. looks like there's no official naming conventions for them in python. So, how do you name them or what do you think is a sensible naming convention?
Quoting https://www.python.org/dev/peps/pep-0008/#package-and-module-names:
Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.
For classes:
Class names should normally use the CapWords convention.
And function and (local) variable names should be:
lowercase, with words separated by underscores as necessary to improve readability
See this answer for the difference between a module, class and package:
- A Python module is simply a Python source file, which can expose classes, functions and global variables.
- A Python package is simply a directory of Python module(s).
So PEP 8 tells you that:
- modules (filenames) should have short, all-lowercase names, and they can contain underscores;
- packages (directories) should have short, all-lowercase names, preferably without underscores;
- classes should use the CapWords convention.
PEP 8 tells that names should be short; this answer gives a good overview of what to take into account when creating variable names, which also apply to other names (for classes, packages, etc.):
- variable names are not full descriptors;
- put details in comments;
- too specific name might mean too specific code;
- keep short scopes for quick lookup;
- spend time thinking about readability.
To finish, a good overview of the naming conventions is given in the Google Python Style Guide.
Here is a link for different types of Python name conventions:
Type Public Internal Packages lower_with_underModules lower_with_under_lower_with_underClasses CapWords_CapWordsExceptions CapWordsFunctions lower_with_under()_lower_with_under()Global/Class Constants CAPS_WITH_UNDER_CAPS_WITH_UNDERGlobal/Class Variables lower_with_under_lower_with_underInstance Variables lower_with_under_lower_with_underMethod Names lower_with_under()_lower_with_under()Function/Method Parameters lower_with_underLocal Variables lower_with_under
The style guide for Python is based on Guido’s naming convention recommendations.
See Python PEP 8: Function and Variable Names:
Function names should be lowercase, with words separated by underscores as necessary to improve readability.
Variable names follow the same convention as function names.
mixedCase is allowed only in contexts where that's already the prevailing style (e.g. threading.py), to retain backwards compatibility.
The Google Python Style Guide has the following convention:
module_name,package_name,ClassName,method_name,ExceptionName,function_name,GLOBAL_CONSTANT_NAME,global_var_name,instance_var_name,function_parameter_name,local_var_name.
A similar naming scheme should be applied to a CLASS_CONSTANT_NAME