Static method

 


#!static mathod
"""
Sada mathod kono variable set kora jai na...sudhu method ke call kora jai
class diye ar object diye"""

class Mobile:
    model="realme" #class variable

    @staticmethod
    def show(p):
        price=p  #static variablee set holo
        print ("price: ",p)


# static method call korlam class diye, kaj hobe
Mobile.show(1000)


#object banalam
realme=Mobile()

#object diye call korlam object diye, kaj hobe
realme.show(500)

#print(realme.price) #?object diye static method ar variable call kora ja nah
#print(Mobile.price)  #?class diye static method ar variable call kora ja nah

Comments

Popular posts from this blog

D WEB LINK