is there a way to call @staticmethod when using @classmethod
@dataclass class Piza: ingridients: List @classmethod def make_Pizza(cls, ingrid, allerg=False): ingridients = ingrid if allerg: return cls(make_for_allerg(ingrid, allerg)) return cls(ingrid) @staticmethod def make_for_allerg(ingrid, allerg): return ingrid.append(allerg) test no allergies:
Piza.make_Pizza(['tomato', 'cheese']) Piza(ingridients=['tomato', 'cheese'])
test with allergies false:
Piza.make_Pizza(['tomato', 'cheese'], allerg='pickle') --------------------------------------------------------------------------- NameError Traceback (most recent call last) in () 1 ----> 2 Piiza.make_Piza(['tomato', 'cheese'], allerg='pickle')
in make_Pizza(cls, ingrid, allerg) 7 ingridients = ingrid 8 if allerg: ----> 9 return cls(make_for_allerg(ingrid, allerg)) 10 return cls(ingrid) 11
NameError: name 'make_for_allerg' is not defined