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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *