I am very rusty on OOP. Now my question is, how exactly would I go about calling a class variable?
I know to call an __init__ variable you would do the following:
class HelloWorld:
def __init__(self):
self.hello = "Hello"
def world(self):
print self.hello + "World"
How do I call a variable not initialized in the class though? Which of the following would be correct?
class HelloWorld:
hello = "Hello"
def world(self):
#Do I use self?
print self.hello + "World"
#Do I use the class name?
print HelloWorld.hello + "World"
I am just confused on whether I should be using self or the class name. Most examples I see are using self, but the one on Tutorials Point uses the class's name. Please elaborate, thank you!