Skip to content

Instantly share code, notes, and snippets.

@isabelcosta
Created March 13, 2021 20:13
Show Gist options
  • Save isabelcosta/c14c4c9a4a098a17807e5bda2df92ac3 to your computer and use it in GitHub Desktop.
Save isabelcosta/c14c4c9a4a098a17807e5bda2df92ac3 to your computer and use it in GitHub Desktop.
Python dataclass simple example
# https://docs.python.org/3/library/dataclasses.html
from dataclasses import dataclass
@dataclass
class Youtuber:
"""Class for defining youtubers."""
name: str
categories: list[str]
youtubers = []
youtubers.append(Youtuber("Chris Stuckmann", ["movie-reviews"]))
youtubers.append(Youtuber("Double Toasted", ["movie-reviews"]))
youtubers.append(Youtuber("The Fitness Marshall", ["fitness"]))
for youtuber in youtubers:
print(f"{youtuber.name}'s categories are: {youtuber.categories}")
@isabelcosta
Copy link
Author

Aww thank you @haelmj 🙌 So nice someone other than me gets to learn from this gist/post 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment