Whenever I do
from 'x' import 'y' I was wondering which one is considered the 'module' and which is the 'package', and why it isn't the other way around?
A Python module is simply a Python source file, which can expose classes, functions and global variables.
When imported from another Python source file, the file name is treated as a namespace.
A Python package is simply a directory of Python module(s).
For example, imagine the following directory tree in
mypackage/__init__.py <-- this is what tells Python to treat this directory as a package mypackage/mymodule.py
So then you would do:
from mypackage.mymodule import myclass
protected by gnat Feb 5 at 12:09
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?