What is a convention to name a private method in Python?

Experience Level: Junior
Tags: Python

Answer

The private methods should be prefixed with double underscore.

Example:

def __add(x: int, y: int) -> int:
    return x + y;

Python for beginners
Python for beginners

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

Test yourself