Calling a method from a parent class in Python -


can me correct syntax call method __get_except_lines(...) parent class?

i have class method shown below. particular method has 2 underscores because don't want "user" use it.

newpdb(object)     myvar = ...     ...     def __init__(self):         ...     def __get_except_lines(self,...):         ... 

in separate file have class inherits class.

from new_pdb import newpdb      pdblig(newpdb):         def __init__(self):             ....             self.cont = newpdb.myvar             self.cont2 = newpdb.__get_except_lines(...) 

and attribute error confuses me:

attributeerror: type object 'newpdb' has no attribute '_pdblig__get_except_lines' 

your problem due python name mangling private variable (http://docs.python.org/2/tutorial/classes.html#private-variables-and-class-local-references). should write:

newpdb._newpdb__get_except_lines(...) 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -