0
def my_func():
    x = Loader.__get_classes_from_module("string","string") # this line causes an error

class Loader(object):
    def get_tests(self, test_prefix="", tags=None, exclude=False):
        # code here

    @staticmethod
    def __get_classes_from_module(f, prefix_class_name=None):
        # code here

In the above code, I get an error stating that AttributeError: type object 'Loader' has no attribute '__get_classes_from_module'. What am I doing wrong?

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
Aditya
  • 551
  • 5
  • 26
  • You put two underscores. – OneCricketeer Jul 28 '17 at 14:05
  • You should call it with `Loader._Loader__get_classes_from_module`. – Willem Van Onsem Jul 28 '17 at 14:07
  • 1
    Because of [name mangling](https://docs.python.org/2/tutorial/classes.html#private-variables-and-class-local-references), your method `__get_classes_from_module` is not actually accessible from outside the class by that name. Considering you want to use it from outside the object itself, you might want to drop the two leading underscores and just call it `get_classes_from_module`. – Kendas Jul 28 '17 at 14:08

0 Answers0