Skip to content

Commit

Permalink
'Solution_v1.02'
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroPieskov committed Nov 10, 2024
1 parent babc540 commit 0f6730b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ def __init__(self, min_amount: int, max_amount: int) -> None:
def __set_name__(self, owner: object, name: str) -> None:
self.protected_name = "_" + name

def __get__(self, instance: object, owner: type) -> str:
def __get__(self, instance: object, owner: type) -> int:
return getattr(instance, self.protected_name)

def __set__(self, instance: object, value: int) -> None:
if not isinstance(value, int):
raise TypeError
raise TypeError('Value must be an integer')
if not (self.min_amount <= value <= self.max_amount):
raise ValueError
raise ValueError(f'Value must be between {self.min_amount} and {self.max_amount}')
setattr(instance, self.protected_name, value)


Expand Down Expand Up @@ -65,7 +65,3 @@ def can_access(self, visitor: Visitor) -> bool:
return True
except (ValueError, TypeError):
return False


Vasia = Visitor("Vasia", age=35, weight=150, height=120)
print(Vasia)

0 comments on commit 0f6730b

Please sign in to comment.