Skip to content

Instantly share code, notes, and snippets.

View wuub's full-sized avatar

Wojciech Bederski wuub

View GitHub Profile
@wuub
wuub / money.py
Created March 28, 2017 08:05 — forked from tauzen/money.py
Python DDD - Value Object idea. Immutable attributes, methods, structural equality.
from collections import namedtuple
class Money(namedtuple('Money', ['amount', 'currency'])):
def add(self, amount):
return Money(self.amount + amount, self.currency)
m = Money(20, 'USD')
print(m)
# Money(amount=20, currency='USD')