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.

Python for beginners
Python for beginners

Are you learning Python ? Try our test we designed to help you progress faster.

Test yourself