MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / Category

Class Category

projects/Expense-Tracker/item.py:28–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26
27@dataclass
28class Category:
29 name: str
30 subcategory: Optional[str] = None
31
32 def __str__(self):
33 if self.subcategory is None:
34 return f"{self.name}-NoSubcategory"
35 else:
36 return f"{self.name}-{self.subcategory}"
37
38 def __eq__(self, other):
39 return self.name == other.name and self.subcategory == other.subcategory
40
41 def is_same_category_name(self, other):
42 return self.name == other.name
43
44
45@dataclass

Calls

no outgoing calls