Closed khanna7 closed 2 years ago
Daniel says that this should work, we'll reproduce the error when Git is fixed up and troubleshoot it then.
Assuming self.female is 0 or 1, and that that self.race is not None then yeah, self.smoker should get assigned.
Fixed as suggested in https://github.com/khanna7/cadre/commit/c367a8bf26c446e6c29a60a2cd505ca0d2e96537. This question at next code review.
Per discussion with Daniel, What I have done is right (and it works). If I want to assign self.smoker=self.assign_smoker_status(), I need to return self.smoker from the “assign_smoking_status” method.
https://github.com/khanna7/cadre/blob/2829019039c741f71c86dc59d25a5f86d1912ed0/python/pycadre/cadre_person.py#L29
I am calling a class method called
assign_smoker_status
on thePerson
class in its__init__
method, as shown in the line referenced in this issue.(The class method is defined here. )
Assigning the smoker status depends on other attributes, and is a bit involved. I therefore wrote a new method to assign it. But, calling the method inside
__init__
, as I have done, doesn't seem to work. All smoking statuses are gettingNone
.Any thoughts on how to fix this?