Modules are primarily namespaces, that’s their most important job. Over the long haul you’ll be much happier if you think about them that way. Packages are mostly a hierarchy of modules, and thus of namespaces. The hierarchy of code is important information when you’re trying to figure out what’s going on: if you disguise it with imports and renames you may have a harder time understanding the code down the road. Thats why the Zen Of Python includes the line
Namespaces are one honking great idea – let’s do more of those!
Nesting is also (well, this is a personal thing for me) a more elegant way of hiding complexity. I much prefer:
import animation.rig.pose as pose
pose.set("zero", *cmds.ls(sl=True))
pose.delete("zero")
existing_poses = pose.list()
To a hypothetical alternative like
import animation.rig.pose.setRigPose as setRigPose
import animation.rig.pose.deleteRigPose as deleteRigPose
import animation.rig.pose.listRigPoses as listRigPoses
setRigPose("zero", *cmds.ls(sl=True))
deleteRigPose("zero")
existing_poses = listRigPoses()
Without the nesting you have to choose longer names anyway to avoid name clashes, so in most complex code it’s more or less a wash when it comes to typing - but the dotted version is somewhat easier to track back to the originating modules. Also, it’s a convenient place to store things besides functions. For example, animation.rig.pose might contain some constants that are handy:
ZERO = 'engineeringMadeMeCallThisSomethingStupidPose'
BIND = 'bindPose'
#... etc
which can ward off potential typos:
pose.set(pose.ZERO, *cmds.ls(sl=True))
… and which, naturally, can’t be done in a one module = one function system.
All that said, one module = one function is fine if the function is complex (and self contained) and you’d just like to keep it its own file. However any time a single function is big enough and complex enough to warrant a file to itself it’s probably in need of a refactor anyway: there is probably some good reusable code buried deep in there that could be brought out and made useful.
And yes: in the system you sketched out above you can’t access anything besides the eponymous function unless you do separate imports. Moreover it means you’ll see the same name in different contexts meaning different things, and will have to hop up to the imports at the top of your file to disambiguate. Not fun.
You might find this link has some useful tips.