Why would you use a private method in Python?
Experience Level: Junior
Tags: Python
Answer
Private methods are used to hide a method from the code that is outside of the class that holds the private method.
This is used for encapsulation.
Related Python job interview questions
How do you display a number of items in a list in Python?
Python JuniorWhat is a private method in Python?
Python JuniorHow do you pass an argument to a class constructor in Python?
Python JuniorHow do you define a constructor in a class in Python?
Python JuniorWhat is a convention to name a protected method in Python?
Python Junior