fromtextwrapimportdedentfromdataclassesimportdataclass@dataclassclassPerson:
__instance=Nonename: strage: introle: strlanguage: strdef__new__(cls, *args, **kwargs):
ifcls.__instanceisNone:
cls.__instance=super().__new__(cls)
returncls.__instancedef__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! """
)
returnbrief_descriptiondefmain() ->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!
👨💻About me:
⚡ 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