I am a beginner in Python and I am wondering how to prevent methods starting with an underscore (_) from being imported. I have a class called Scrapper which has four methods: get, save, _is_data_available, and _collecting_data. I only want the get and save methods to be imported by other modules.I tried adding all = ['get', 'save'] outside the class, but this did not work. How can I do this?
            Asked
            
        
        
            Active
            
        
            Viewed 25 times
        
    0
            
            
         
    
    
        Devlpr Khan
        
- 1
- 2
- 
                    1A method can't be *imported*, because it belongs to the namespace of a class, not a module. So `__all__` doesn't have an effect here. – slothrop Aug 23 '23 at 10:23
- 
                    The underscore is sufficient. If a third-party caller chooses to ignore that convention, you should never try to prevent it. (Of course, if your own code ignores it, that's a bug which needs fixing). – ekhumoro Aug 23 '23 at 10:33