Open this example in the interactive library
Source code
class User:
def __init__(self, name):
self.name = name
@classmethod
def from_record(cls, record):
return cls(record['name'])
print(User.from_record({'name':'Ada'}).name)Sample output
Ada
