2

I create based abstract class in python which is based class for all child classes and implement some functions which will be redundant to write each time in every child class.

class Element:

    ###SITE###
    __sitedefs = [None]

    def getSitedefs(self):
        return self.__sitedefs


class SRL16(Element):

    ###SITE###
    __sitedefs = ['SLICEM']

Ther result is logical in on hand beacuse I get the value from the based class where I declare the value but otherwise I overwite it in child one. My question is how to get from

srl = SRL16()
srl.getSitedefs()

SLICEM not NONE

Probably I missunderstending something very based but please help.

Best regards

PaulWebbster
  • 1,480
  • 2
  • 14
  • 27

1 Answers1

7

Your problem's is due to name mangling. See eg: What is the meaning of a single- and a double-underscore before an object name?.

If you change all the __sitedefs by _sitedefs then everything should work as expected.

Community
  • 1
  • 1
hivert
  • 10,579
  • 3
  • 31
  • 56