Skip to content

Commit

Permalink
Recommend adding decorator in the README
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jan 15, 2019
1 parent 3ed7a02 commit 1a5ea8c
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,15 @@ class InventoryItem:
return self.unit_price * self.quantity_on_hand
```

and replace the decorator, including a directory pattern to synchronize instances:
and decorate it with directory pattern to synchronize instances:

```python
from datafiles import datafile

@datafile("inventory/items/{self.name}.yml") # <= save instances in the `inventory/items` directory
@datafile("inventory/items/{self.name}.yml")
@dataclass
class InventoryItem:
"""Class for keeping track of an item in inventory."""

name: str
unit_price: float
quantity_on_hand: int = 0

def total_cost(self) -> float:
return self.unit_price * self.quantity_on_hand
...
```

Then, work with instances of the class as normal:
Expand Down

0 comments on commit 1a5ea8c

Please sign in to comment.