In Python imports, the dot . is used to denote a relative import. The line from
.chord import Chord
is importing the Chord class or object from the chord module which is at the same level as the current module in the package hierarchy.
A single dot . before the module name indicates that the import is relative to the current package level. Here's a brief explanation of the notation:
. (single dot): Indicates that the module is in the same package level as the current module.
.. (two dots): Indicates that the module is one level up in the package hierarchy.
... (three dots): Indicates that the module is two levels up in the package hierarchy.
my_package/
__init__.py
module_a.py
module_b.py
sub_package/
__init__.py
module_c.py
# If you wanted to import module_b.py from module_a.py,
# you could use a relative import like this inside module_a.py:
from .module_b import some_function
# Likewise, if you wanted to import module_a.py from module_c.py, you could use:
from ..module_a import some_function