object patch
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import fileparse
|
||||
import stock
|
||||
|
||||
class Portfolio(object):
|
||||
class Portfolio:
|
||||
def __init__(self):
|
||||
self._holdings = []
|
||||
|
||||
|
||||
@@ -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.
|
||||
'''
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# tableformat.py
|
||||
|
||||
class TableFormatter(object):
|
||||
class TableFormatter:
|
||||
def headings(self, headers):
|
||||
'''
|
||||
Emit the table headers
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user