On 11/25/25 1:42 PM, bjotta via Python-list wrote:
> I want to be able to restrict / name mangle the usage.
> To avoid this being possible.
> 
> '''
> from library.math import np.
> '''

Fascinating. I would never have thought to do an import like that and I
have never heard of anyone doing such a thing.  I can't say I have ever
seen it in any python code in the wild either.

Of course Python only imports each module once, so importing np from
library.math would get you the same module as when you import numpy. So
there's no difference as far as dependencies are concerned.

> There are reasons for this, but for example at work we explicitly install all 
> dependencies we use in our program.
> 
> If someone starts to use sub-dependency from a library without explicitly 
> installing it. The next time the library updates and the maintainers decides 
> to update to using numba or something else the code wont work.

I don't see how importing from library.math vs directly from numpy has
any bearing on that policy.  Either way you're importing numpy so that
will have to be installed.  Besides, isn't this really a documentation
issue? Perhaps an automated script can enumerate the dependencies for
you so you can ensure your policy is followed when code is committed.

-- 
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to