utility functions within a class?
bruno at modulix
onurb at xiludom.gro
Tue May 9 04:55:07 EDT 2006
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.
>
> In python, as discussed earlier :), you can make them semi-private by
> using the '__method_name'
Blair, please, don't give bad advices. The 'double-leading-underscore'
stuff has some side-effects (name-mangling), and is meant to protect an
attribute from accidental overloading. The convention for 'protected'
attributes (which should really be named 'implementation attributes') is
a *single* leading underscore.
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list