from textwrap import dedent
from dataclasses import dataclass
@dataclass
class Person:
__instance = None
name: str
age: int
role: str
language: str
def __new__(cls, *args, **kwargs):
if cls.__instance is None:
cls.__instance = super().__new__(cls)
return cls.__instance
def __str__(self) -> str:
brief_description = dedent(
f"""
Hi, my name is {self.name} β I'm a {self.role} in {self.language}.
I'm {self.age} years old and have been programming for over 1 year.
Thank you for stopping by!
"""
)
return brief_description
def main() -> None:
me = Person(name="Lev", age=17, role="Web developer", language="Python")
print(me)
if __name__ == "__main__":
main()
# Hi, my name is Lev β I'm a Web developer in Python.
# I'm 17 years old and have been programming for over 1 year.
# Thank you for stopping by!
- β‘ I like to write code
- π§ Creating my own projects
- π Happy to have any real practice
- π§ Responsible, limited and very pedantic
- π I am self-taught
- π I follow the basic principles of programming: DRY, KISS, YAGNI, SOLID