Created
January 22, 2022 15:34
-
-
Save temmyzeus/418c117c6d8ef1d783b90b8192c71af7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Item: | |
# this is a class variable | |
percent_off = 0.1 | |
def __init__(self, item_name, price): | |
self.item_name = item_name | |
self.price = price | |
@classmethod | |
def from_list(cls, item_lst): | |
return cls(*item_lst) #notice this calls the class itself and initializes it | |
item = Item.from_list(['Burger', 2.55]) | |
print('Name:', item.item_name, ', Price:', item.price) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment