object patch

This commit is contained in:
David Beazley
2020-05-28 17:52:19 -05:00
parent a83a9cf064
commit a31a9ee0f4
57 changed files with 558 additions and 40 deletions

View File

@@ -3,7 +3,7 @@
import fileparse
import stock
class Portfolio(object):
class Portfolio:
def __init__(self):
self._holdings = []

View File

@@ -2,7 +2,7 @@
from typedproperty import String, Integer, Float
class Stock(object):
class Stock:
'''
An instance of a stock holding consisting of name, shares, and price.
'''

View File

@@ -1,6 +1,6 @@
# tableformat.py
class TableFormatter(object):
class TableFormatter:
def headings(self, headers):
'''
Emit the table headers

View File

@@ -20,7 +20,7 @@ Float = lambda name: typedproperty(name, float)
# Example
if __name__ == '__main__':
class Stock(object):
class Stock:
name = typedproperty('name', str)
shares = typedproperty('shares', int)
price = typedproperty('price', float)
@@ -30,5 +30,16 @@ if __name__ == '__main__':
self.shares = shares
self.price = price
class Stock2:
name = String('name')
shares = Integer('shares')
price = Float('price')
def __init__(self, name, shares, price):
self.name = name
self.shares = shares
self.price = price