pseudoprivate attributes are also useful in larger frameworks or toolsboth to avoid introducing new method names that might accidentally hide definitions elsewhere in the class tree and to reduce the chance of internal methods being replaced by names defined lower in the tree if method is intended for use only within class that may be mixed into other classesthe double underscore prefix virtually ensures that the method won' interfere with other names in the treeespecially in multiple-inheritance scenariosclass superdef method(self) real application method class tooldef __method(self)def other(self)self __method(becomes _tool__method use my internal method class sub (toolsuper)def actions(self)self method(runs super method as expected class sub (tool)def __init__(self)self method doesn' break tool __method we met multiple inheritance briefly in and will explore it in more detail later in this recall that superclasses are searched according to their left-to-right order in class header lines herethis means sub prefers tool attributes to those in super although in this example we could force python to pick the application class' methods first by switching the order of the superclasses listed in the sub class headerpseudoprivate attributes resolve the issue altogether pseudoprivate names also prevent subclasses from accidentally redefining the internal method' namesas in sub againi should note that this feature tends to be of use primarily for largermultiprogrammer projectsand then only for selected names don' be tempted to clutter your code unnecessarilyonly use this feature for names that truly need to be controlled by single class although useful in some general class-based toolsfor simpler programsit' probably overkill for more examples that make use of the __x naming featuresee the lister py mix-in classes introduced later in this in the multiple inheritance sectionas well as the discussion of private class decorators in if you care about privacy in generalyou might want to review the emulation of private instance attributes sketched in the section "attribute access__getattr__ and __setattr__on page in and watch for the more complete private class decorator we'll build with delegation in although it' possible to emulate true access controls in python classesthis is rarely done in practiceeven for large systems pseudoprivate class attributes