Условная логика Nuspec

Вы объявляете локальную переменную, а не переменную класса. Чтобы установить переменную экземпляра (атрибут), используйте

class Example(object):
    def the_example(self):
        self.itsProblem = "problem"  # <-- remember the 'self.'

theExample = Example()
theExample.the_example()
print(theExample.itsProblem)

. Чтобы установить переменную класса (статический член a.k.a.), используйте

class Example(object):
    def the_example(self):
        Example.itsProblem = "problem"
        # or, type(self).itsProblem = "problem"
        # depending what you want to do when the class is derived.

0
задан Kaizerwolf 22 March 2019 в 14:52
поделиться