Apologies upfront if this is a dupe; I search for "_curried python" and got 14 results, and then simply _curried" and that only bumped up to 33 results, and none seemed to help out...
The problem: I came across what I originally thought was a typo in our codebase today, here is the suspect:
student.recalculate_gpa()
Now, I suspect it to be a typo because student
is an instance of a Student
class that has no recalculate_gpa
method. However, it does have a calculate_gpa
method:
class Student(User):
...
def calculate_gpa(self):
# some calculations...
(Where User
is the standard django user class.) But, the code wasn't erroring, which made no sense to me. So I did an inspect and found this:
... (a bunch of methods)
('calculate_gpa', <unbound method Student.calculate_gpa>),
... (some more methods)
('recalculate_gpa', <unbound method Student._curried>),
Strange, recalculate_gpa
is in fact a method. But where on earth does it come from? I grep'd for "_curried" in our codebase and found nothing, so this must be some Django-related behavior. Certainly I would expect that somewhere in our project we've described how dynamically named functions are formed since recalculate
seems like a plausible derivative of calculate
, but I honestly have no idea where to start looking.
Thus, my question: how are curried methods like the one above generated, and where should I start looking to discover how our own codebase is curry-ing?
Thanks a ton in advance!