MCPcopy Create free account
hub / github.com/dabeaz-course/python-mastery / Stock

Class Stock

Solutions/8_1/stock.py:6–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4from validate import String, PositiveInteger, PositiveFloat
5
6class Stock(Structure):
7 name = String('name')
8 shares = PositiveInteger('shares')
9 price = PositiveFloat('price')
10
11 @property
12 def cost(self):
13 return self.shares * self.price
14
15 def sell(self, nshares):
16 self.shares -= nshares
17
18if __name__ == '__main__':
19 from reader import read_csv_as_instances

Callers

nothing calls this directly

Calls 3

StringClass · 0.90
PositiveIntegerClass · 0.90
PositiveFloatClass · 0.90

Tested by

no test coverage detected