Skip to content

Instantly share code, notes, and snippets.

@ItsDrike
ItsDrike / descriptors.py
Created January 3, 2021 00:42
Explanation of python's descriptors
class ClassicalItem:
"""
The classical solution, there's nothing special about it,
but if we came from old implementation without this protection,
we would loose backwards compatibility, because `amount` attribute
wouldn't be accessible anymore.
"""
def __init__(self, description, amount, price):
self.description = description
self.set_amount(amount)