An example of using a class-level variable to count how many objects of this class were created.

preview_player
Показать описание

#class #oop #objectorientedprogramming #counter #objectfactory
#python #python3 #development #developer #programming #it #coding #program #programmer #programminglanguage #code #coding #pythonprogramming #pythoncode #software
#softwaredeveloper #geek #computers #learntocode #learnpython
Рекомендации по теме
Комментарии
Автор

You had to write the class name "Item" twice in your code, that means that if you ever wanted to change the name of the class you would need to go hunt everywhere it's mentioned. Instead, use type(self) or self.__class__. Another note is the method you defined in the class, it's pointless, you can just access the attribute directly, you don't need a getter.

רועיכהן-כתובתישנה
Автор

The same, but easier is achieved with classmethods

igorgrosu
Автор

ITS IMTAZ KHAN:
BRO I THINK YOU HAVE STUDIED IN W3SCHOOLS. COM✌️
REPLY ME BRO 😢 I NEED TO BE LIKE

saro
welcome to shbcf.ru