Skip to content

Instantly share code, notes, and snippets.

@mohammadali66
Last active September 13, 2022 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohammadali66/b4350799ea293d638c5f6427f40ba540 to your computer and use it in GitHub Desktop.
Save mohammadali66/b4350799ea293d638c5f6427f40ba540 to your computer and use it in GitHub Desktop.
from dataclasses import dataclass
from typing import NamedTuple
from collections import namedtuple
@dataclass(frozen=True)
class Name:
first_name: str
surname: str
class Money(NamedTuple):
currency: str
value: int
Line = namedtuple('Line', ['sku', 'qty'])
def test_equality():
assert Money('gbp', 10) == Money('gbp', 10)
assert Name('Harry', 'Percival') != Name('Bob', 'Gregory')
assert Line('chair', 10) == Line('chair', 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment