Closed 0x326 closed 5 years ago
Or, if you wanted to use a native type, you could do something like this:
from typing import NamedTuple
class Card(NamedTuple):
name: str
cmc: int
# Optional functions here...
# Later...
card = Card(**response_dict)
Feel free to make a PR with the changes if init is the preferred way. I'm not a huge python guy, so I personally can't speak to the benefits of one over the other :)
I noticed in #15 that we changed from
__init__
to__new__
in classes likeCard
andSet
. I was wondering what the advantage of this is? It seems like__init__
offers more utility over__new__
, since IDEs can suggest class members and, with Python 3.6 type annotations, could even infer their type (see below)