You are required to create a Python module that should expose only specific functions when imported. How would you hide the internal implementation details and expose only the necessary functions?
- a) Use the __all__ attribute
- b) Define functions inside a class
- c) Use double underscores before function names
- d) Create a separate module for each function
To expose only specific functions when importing a Python module, you can define the __all__ attribute at the module level. This attribute is a list of function names that should be considered part of the module's public API, hiding the rest of the implementation details.
Loading...
Related Quiz
- When working with large files, why might the readlines() method not be the most memory-efficient?
- When implementing a recursive algorithm, what is crucial to avoid infinite recursion?
- How is a generator function different from a normal function in Python?
- How does Python handle the absence of method overloading like in some other programming languages?
- In Scikit-learn, the ____ class is used for feature scaling.