[Biopython-dev] private methods/vars

ik3 at mail.inf.tu-dresden.de ik3 at mail.inf.tu-dresden.de
Mon Jun 23 13:48:42 EDT 2003


Thanks for your feedback!

But i'm a little bit confused at the moment.
The book that i have about python said that the doubel underscore before a
class method means it won't be visible for other classes (thats my
definition of private (isn't it ?)).

If i tried following things:

class TestClass:
  def __init__(self):
     return None

  def __hello1(self):
     print 'hello1'

  def _hello2(self):
     print 'hello2'

test = TestClass()

then i got the difference between test.__hello1() that i can't call even
in the same module and test._hello() that i can call from other classes in
the module.

Right or Wrong ?

And in the language reference there is written that __* 
means	'Class-private name mangling'.

Because i'm german and my english isn't the best it could be that i don't
really understand these concept. So if i'm wrong what exactly is the
meaning of __* ? For mangling i couldn't find a proper translation.

Sorry i fear the thread is a little bit off topic. But eventually you have
a answer for me.

Greetings
Ingo



More information about the Biopython-dev mailing list