utility functions within a class?

blair.bethwaite at gmail.com blair.bethwaite at gmail.com
Sun May 7 20:46:16 EDT 2006


It sounds like all you want is some encapsulation, the following makes
methods __head__ and __body__ "private" - the double underscores are
important.  I'd suggest reading the Object bits of the python tutorial
also.

class HTMLWrapper:

   def generate(self, ...):
      ...
      self.__head__(foo)
      ...
      self.__body__(bar)
      ...

   def __head__(self, ...):
      ...

   def __body__(self, ...):
      ...




More information about the Python-list mailing list