I am new in Python OOP and I try to understand one specific line of code.
This is a part of a code:
from random import randrange
class Pet():
hunger_threshold = 10
def __init__(self, name = "Kitty"):
self.name = name
self.hunger = randrange(self.hunger_threshold)
My question is, what is the different between
self.hunger = randrange(self.hunger_threshold) #1)
and
self.hunger = randrange(hunger_threshold) #2)
And why is it valid to to the 2) before doing
self.hunger_threshold = hunger_threshold
I hope someone can get me understanding.