Below is a greatly simplified version of my code. After __init__()there are several functions.
I am trying to use functools.partialto create different versions of a base comparisonfunction that refers to a function created earlier in the class calculation. One version of this comparison function may be grade_comparisonas shown below.
class Analysis(mybaseclass):
def __init__(self, year, cycle):
....
def calculation(self, subject):
print subject
def comparison(subject, **kwargs):
self.calculation(subject)
grade_comparison = functools.partial(comparison, infoList1 = ['A', 'B'])
When I run my code, the error appears NameError: global name 'self' is not defined. I tried adding selfto many combinations that seemed logical - one example below.
self.grade_comparison = functools.partial(comparison, self, infoList1 = ['A', 'B'])
This change led to this error, NameError: name 'self' is not defined
When I add myself to the comparison function (see below):
def comparison(self, subject, **kwargs):
self.calculation(subject)
, TypeError: comparison() takes at least 2 arguments (1 given). , , ! , .