MemotivaObject-oriented programming

What is name mangling?

Object-oriented programming

Audio flashcard · 0:14

Nortren·

What is name mangling?

0:14

Name mangling is when Python rewrites attribute names that start with two underscores but do not end with two underscores. The name is rewritten to include the class name, so dunder x in class A becomes underscore A double underscore x. This avoids accidental name clashes in subclasses.
docs.python.org