Skip to content

Instantly share code, notes, and snippets.

@highsmallxu
Created May 31, 2020 15:20
Show Gist options
  • Save highsmallxu/a7acb19869d7867c92736f42277eb5de to your computer and use it in GitHub Desktop.
Save highsmallxu/a7acb19869d7867c92736f42277eb5de to your computer and use it in GitHub Desktop.
import collections
ArticleNamedTuple = collections.namedtuple("ArticleNamedTuple", ["date", "writer"])
class ArticleAdvancedNamedTuple(ArticleNamedTuple):
__slots__ = ()
article = ArticleAdvancedNamedTuple("2020-01-01", "xiaoxu")
print(article.writer)
# xiaoxu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment