Instance method to return name of attribute to which it assigns a value
Instance method to return name of attribute to which it assigns a value Question: Any way to return name of instance attribute in method it calls on assignment? class MyClass: def __init__(self): self.not_relevant = 0 self.name_to_return = self.assign_own_name() def assign_own_name(self): return "name_to_return" # to replace assert MyClass().name_to_return == ‘name_to_return’ Use case: multiple attribute are initialized …