I am learning oop in python so i am having some problem to understand sefl
keyword properly.
Suppose a program :
class ge:
def __init__(self,a,b):
self.p=a
self.l=b
def ff(self):
aaa=self.p+self.l
print(aaa)
hh=ge(1,2)
hh.ff()
I am confuse why its necessary to use any string with self with dot ? what it means ? Like:
self.a=a and we can change self.a to ay string like self.b , self.c what it means ?? why its necessary ?
My second question is :
what is difference between defining class with parameter and without parameter ?
class hello(object):
def __init__(self,a,v):
self.a=a
self.v=v
def p(self):
f=self.a+self.v
print(f)
he=hello(1,2)
he.p()
if i defined
class hello(object)
its working but
if i defined class like:
class hello():
its also working
but if i defined like:
class hello:
its also working
what is the difference class hello(object):
, class hello()
, class hello: