class def metha(self)self def methb(self)print(self xme too both of these classes work by themselves the problem arises if the two classes are ever mixed together in the same class treeclass ( ) (only in inowthe value that each class gets back when it says self will depend on which class assigned it last because all assignments to self refer to the same single instancethere is only one attribute-- --no matter how many classes use that attribute name this isn' problem if it' expectedand indeedthis is how classes communicate--the instance is shared memory to guarantee that an attribute belongs to the class that uses itthoughprefix the name with double underscores everywhere it is used in the classas in this / filepseudoprivate pyclass def meth (self)self __x def meth (self)print(self __xclass def metha(self)self __x def methb(self)print(self __xclass ( )pass (now is mine becomes _c __x in me too becomes _c __x in two names in meth () metha(print( __dict__i meth () methb(when thus prefixedthe attributes will be expanded to include the names of their classes before being added to the instance if you run dir call on or inspect its namespace dictionary after the attributes have been assignedyou'll see the expanded names_c __x and _c __xbut not because the expansion makes the names more unique within the instancethe class coders can be fairly safe in assuming that they truly own any names that they prefix with two underscorespython pseudoprivate py {'_c __x' '_c __x' this trick can avoid potential name collisions in the instancebut note that it does not amount to true privacy if you know the name of the enclosing classyou can still access either of these attributes anywhere you have reference to the instance by using the fully expanded name ( _c __x moreovernames could still collide if unknowing programmers use the expanded naming pattern explicitly (unlikelybut not designing with classes