where is a difference between creating a variable in a class and assign it a value in __init__
and creating the variable directly in __init__
?
For example:
Example 1:
# I create the var color outside __init__ and assigns a value to it inside __init__
class Car:
color = ""
def __init__(self):
self.color = "green"
Example 2:
# I directly create the variable inside __init__ and not outside __init__ and just assign a value in __init__
class Car:
def __init__(self, color):
self.color = color
Does it make a difference?