Suppose I have a Python module my_class.py (see PEP 8 convention for modules) that holds a class MyClass (see PEP 8 convention for classes).
Now I want to instantiate that class in a module in the same package and would normally do
from .my_class import MyClass
my_class = MyClass()
since PEP 8 proposes this naming scheme for instance variable names here.
However, in this context, my_class already refers to the module my_class.py and the instance variable would therefore shadow the module.
Do PEP 8 or any other sources give any direction on how to proceed here, or is it just up to the developer to think of a different but less intuitive name for the variable?
classrepresents aninstance(rather than "just a class"), the appropriate thing to write would bemy_instance = MyClass(), wouldn't it?MyClassis just an example, in a real useacase the class might not be calledMyClassbut e. g.JsonParser.