Note the following Python module snippets:
foo.py:
class Foo: (...)
bar.py:
import foo foo = foo.Foo()
The variable foo, which was the module object, is overwritten by the Foo object.
I know that I can use other names for the object, for example:
foobar = foo.Foo()
but semantically it makes sense in my code to call it foo, as it will be the only instance.
(I tried to work around this by dropping classes and using only modules, but I returned to using classes because using modules had "stability" issues.)
This is a kind of philosophical question, but what is the โrightโ way to handle these potential names of object / module names?
source share