About 86,900 results
Open links in new tab
  1. Should I use name mangling in Python? - Stack Overflow

    Name mangling can make certain uses, such as debugging and __getattr__() , less convenient. However the name mangling algorithm is well documented and easy to perform manually.

  2. What is name mangling, and how does it work? - Stack Overflow

    Aug 22, 2009 · In python, name-mangling is a system by which class variables have different names inside and outside the class. The programmer "activates" it by putting two underscores …

  3. python - What is the meaning of single and double underscore …

    Mangling is a feature in Python that modifies the name of a class member to make it harder to access directly from outside the class. It's a technique used to create "pseudo-private" …

  4. Python name mangling for private class (with double underscore)

    May 3, 2022 · The transformation inserts the class name, with leading underscores removed and a single underscore inserted, in front of the name. For example, the identifier __spam …

  5. What is the benefit of private name mangling? - Stack Overflow

    Python provides private name mangling for class methods and attributes. Are there any concrete cases where this feature is required, or is it just a carry over from Java and C++? Please …

  6. python - Should name mangling be used in classes that are …

    Jan 12, 2024 · 4 The entire point of using double-underscore name-mangling is to prevent name collisions in subclasses. That's it. So this is precisely the behavior that is intended, what you …

  7. python - Is this summary of the purpose of name mangling correct ...

    Feb 28, 2021 · 2 Name mangling is unnecessary for a child class to override a method with more parameters. The purpose is to prevent overriding of a method, particularly the overriding of a …

  8. python - Private attribute name mangling inheritance - Stack …

    Nov 20, 2021 · 3 Name mangling is done at byte code compilation time, so the name mangling depends on where the function was defined, not what it was called through. Child doesn't have …

  9. Python double underscore mangling - Stack Overflow

    Jun 18, 2016 · Name mangling occurs during the evaluation of a class statement. In the case of Bar, the __cache attribute is not defined as part of the class, but rather added to a specific …

  10. python name mangling and global variables - Stack Overflow

    May 14, 2020 · Shameless plug of my question about that from a long time ago: How to access private variable of Python module from class. Another fun fact: name mangling won't happen …