There is limited support for class-private identifiers. Any identifier of the form __spam (at least
two leading underscores, at most one trailing underscore) is textually replaced with _classname__spam,
where classname is the current class name with leading underscore(s) stripped. This mangling is done
without regard to the syntactic position of the identifier, so it can be used to define class-private
instance and class variables, methods, variables stored in globals, and even variables stored in instances.
private to this class on instances of other classes. Truncation may occur when the mangled name would
be longer than 255 characters. Outside classes, or when the class name consists of only underscores,
no mangling occurs.
It is easy to add iterator behavior to your classes. Define a __iter__() method which returns an object
with a next() method. If the class defines next(), then __iter__() can just return self.