Closed Matt-DESTROYER closed 2 months ago
Improved:
class Tag:
def __init__(self: Self, name: str, text: str = '', **attributes: str) -> None:
self.name = name
self.text = text
self.attributes: dict[str, str] = attributes
self.children: list[Tag] = []
I'd also recommend that the .attribute()
and .id()
methods be removed since they are not useful.
Improved:
class Tag: def __init__(self: Self, name: str, text: str = '', **attributes: str) -> None: self.name = name self.text = text self.attributes: dict[str, str] = attributes self.children: list[Tag] = []
I'd also recommend that the
.attribute()
and.id()
methods be removed since they are not useful.
Code would have to be remade to support the deprecation of these methods, since the class Tags
has nested classes that inherit Tag
, and then use .attribute()
.
Could keyword arguments be automatically used as attributes for Tags?
I'm thinking something like: