utility functions within a class?

John Salerno johnjsal at NOSPAMgmail.com
Mon May 8 10:04:34 EDT 2006


John Salerno wrote:
> blair.bethwaite at gmail.com wrote:
>> John Salerno wrote:
>>> What I originally meant was that they would not be called from an
>>> instance *outside* the class itself, i.e. they won't be used when
>>> writing another script, they are only used by the class itself.
>>
>> Yep, so you want to encapsulate the functionality that those methods
>> provide, which is the whole point of building them in a class in the
>> first place.  And you want them to be private to the class so that they
>> do not form part of the classes public/external interface.
> 
> But it's right that they should still be regular instance methods? So 
> from within the class I still call them as self._generate_head(), etc.?

I tried the underscore method, but I was still able to call it as a 
regular instance method in the interpreter. Is that what's supposed to 
happen?



More information about the Python-list mailing list