Re: Proposal: private keyword for import statements to hide module dependencies

Thomas Passin <[email protected]>
Newsgroups gmane.comp.python.general
Message-ID <[email protected]>
On 11/25/2025 3:42 PM, bjotta via Python-list wrote:
> It seem like you are talking about classes and sub-classes. I was talking about dependencies in projects.
> 
> 
> e..g I create a library that has some dependencies (numpy here)
> Inside the library there is a file importing numpy for example.
> 
> '''
> import numpy as np
> 
> def stock_earnings(winnings, losses):
>      return winnings - losses
>      
> '''
> 
> I want to be able to restrict / name mangle the usage.
> To avoid this being possible.
> 
> '''
> from library.math import np.
> '''
> 
> 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.
> 
> That was the Idea behind the "private" keyword. Any other suggestion to that part?

I don't see how a private keyword would help.  But in Python programs, 
you don't get upgraded automatically.  You can use pip freeze to capture 
the current version of all libraries, and then use those versions during 
a new install. So there is a way to keep control of the various versions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.