From cf7e9d2666ce98b6bdace558ca08c9228c55d2eb Mon Sep 17 00:00:00 2001 From: Oz Tiram Date: Mon, 18 Mar 2024 17:05:39 +0100 Subject: [PATCH] Add public get method to the base class --- src/plette/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plette/models.py b/src/plette/models.py index 485a853..ca7fa54 100644 --- a/src/plette/models.py +++ b/src/plette/models.py @@ -57,6 +57,12 @@ def __getitem__(self, key): value = self.__dict__[key] return value + def get(self, key, default=None): + try: + return self[key] + except KeyError: + return default + @dataclass class Hash(BaseModel):