Protected& private methods in python

Hello all,
During my python training, I came across OOPS .concepts.This code shows an attribute error while I’m trying to run it

class Parent(object):
    def _protected(self):

    def __private(self):

class Child(Parent):
    def foo(self):
        self._protected()   # This works

    def bar(self):

The protected method works and the private method doesn’t work does it mean protected works while inheritance and private don’t?

That’s what private means. Non-inheritable.

1 Like