dimanche 28 juillet 2019

How best to create object variables from a method

What is the best way to set object variables that are set by a method? Is the methodology below where self.toppings is first defined in __init__() and then the value is set in the select_toppings() method a good practice on how to set the self.toppings variable? Please let me know if you have better suggestions. Thanks.

class Pizza:

    def __init__():
        self.toppings = None 

    def select_toppings(input):
        self.toppings = input  

Aucun commentaire:

Enregistrer un commentaire