I have a question which seems to be rather fundamental but I can\'t seem to find any help on this anywhere.
file_a.py >>
from xyz import XYZ
class A:
Yes, your understanding is wrong. Each module is its own namespace, and only things you explicitly import within that file are available in that namespace.
Contrary to other answers, it is not particularly Pythonic to refer to file_a.XYZ
, although this will work. Instead, you should import XYZ and sys at the top of file_b
.