Hey everyone! I'm developing a Python package, and I've noticed that when I import libraries at the start of one of my modules, they become accessible from outside my package. For instance, I'm importing 'os', 'numpy', and 'Any' from 'typing'. This means someone can do something like 'from mypackage.mymodule import os, np, Any', which isn't ideal for me. Is there a way to hide these imports? I know it might sound silly, but I'm really looking for a solution! I found some partial fixes, but none actually seem to completely obscure the imports, even in Visual Studio Code. I've heard Python isn't built for code privacy, but I'm curious if anyone has advice on how to manage this better, maybe like how Astropy handles their imports by wrapping dependencies.
1 Answer
Honestly, I don't think you can completely hide the imports, but I'm curious why this is an issue for you. Could you share a bit more?
It’s not such a big deal, really! I just want my package to look clean and make it easy for others, especially newcomers, to understand without too much confusion. I know some packages handle their dependencies in a slick way, so I thought there had to be a method!