Skip to content

Commit a31a9ee

Browse files
committed
object patch
1 parent a83a9cf commit a31a9ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+558
-40
lines changed

Solutions/4_10/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# stock.py
22

3-
class Stock(object):
3+
class Stock:
44
'''
55
An instance of a stock holding consisting of name, shares, and price.
66
'''

Solutions/4_10/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/4_4/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# stock.py
22

3-
class Stock(object):
3+
class Stock:
44
'''
55
An instance of a stock holding consisting of name, shares, and price.
66
'''

Solutions/5_8/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# stock.py
22

3-
class Stock(object):
3+
class Stock:
44
'''
55
An instance of a stock holding consisting of name, shares, and price.
66
'''

Solutions/5_8/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/6_12/portfolio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# portfolio.py
22

3-
class Portfolio(object):
3+
class Portfolio:
44
def __init__(self, holdings):
55
self._holdings = holdings
66

Solutions/6_12/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# stock.py
22

3-
class Stock(object):
3+
class Stock:
44
'''
55
An instance of a stock holding consisting of name, shares, and price.
66
'''

Solutions/6_12/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/6_15/portfolio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# portfolio.py
22

3-
class Portfolio(object):
3+
class Portfolio:
44
def __init__(self, holdings):
55
self._holdings = holdings
66

Solutions/6_15/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# stock.py
22

3-
class Stock(object):
3+
class Stock:
44
'''
55
An instance of a stock holding consisting of name, shares, and price.
66
'''

Solutions/6_15/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/6_3/portfolio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# portfolio.py
22

3-
class Portfolio(object):
3+
class Portfolio:
44
def __init__(self, holdings):
55
self._holdings = holdings
66

Solutions/6_3/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# stock.py
22

3-
class Stock(object):
3+
class Stock:
44
'''
55
An instance of a stock holding consisting of name, shares, and price.
66
'''

Solutions/6_3/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/6_7/portfolio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# portfolio.py
22

3-
class Portfolio(object):
3+
class Portfolio:
44
def __init__(self, holdings):
55
self._holdings = holdings
66

Solutions/6_7/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# stock.py
22

3-
class Stock(object):
3+
class Stock:
44
'''
55
An instance of a stock holding consisting of name, shares, and price.
66
'''

Solutions/6_7/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/7_11/portfolio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import fileparse
44
import stock
55

6-
class Portfolio(object):
6+
class Portfolio:
77
def __init__(self):
88
self._holdings = []
99

Solutions/7_11/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typedproperty import String, Integer, Float
44

5-
class Stock(object):
5+
class Stock:
66
'''
77
An instance of a stock holding consisting of name, shares, and price.
88
'''

Solutions/7_11/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/7_11/typedproperty.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def prop(self, value):
2020

2121
# Example
2222
if __name__ == '__main__':
23-
class Stock(object):
23+
class Stock:
2424
name = typedproperty('name', str)
2525
shares = typedproperty('shares', int)
2626
price = typedproperty('price', float)
@@ -30,5 +30,16 @@ def __init__(self, name, shares, price):
3030
self.shares = shares
3131
self.price = price
3232

33+
34+
class Stock2:
35+
name = String('name')
36+
shares = Integer('shares')
37+
price = Float('price')
38+
39+
def __init__(self, name, shares, price):
40+
self.name = name
41+
self.shares = shares
42+
self.price = price
43+
3344

3445

Solutions/7_4/portfolio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# portfolio.py
22

3-
class Portfolio(object):
3+
class Portfolio:
44
def __init__(self, holdings):
55
self._holdings = holdings
66

Solutions/7_4/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# stock.py
22

3-
class Stock(object):
3+
class Stock:
44
'''
55
An instance of a stock holding consisting of name, shares, and price.
66
'''

Solutions/7_4/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/7_9/portfolio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# portfolio.py
22

3-
class Portfolio(object):
3+
class Portfolio:
44
def __init__(self, holdings):
55
self._holdings = holdings
66

Solutions/7_9/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typedproperty import String, Integer, Float
44

5-
class Stock(object):
5+
class Stock:
66
'''
77
An instance of a stock holding consisting of name, shares, and price.
88
'''

Solutions/7_9/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/7_9/typedproperty.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def prop(self, value):
2020

2121
# Example
2222
if __name__ == '__main__':
23-
class Stock(object):
23+
class Stock:
2424
name = typedproperty('name', str)
2525
shares = typedproperty('shares', int)
2626
price = typedproperty('price', float)
@@ -30,5 +30,15 @@ def __init__(self, name, shares, price):
3030
self.shares = shares
3131
self.price = price
3232

33+
class Stock2:
34+
name = String('name')
35+
shares = Integer('shares')
36+
price = Float('price')
37+
38+
def __init__(self, name, shares, price):
39+
self.name = name
40+
self.shares = shares
41+
self.price = price
42+
3343

3444

Solutions/8_1/portfolio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import fileparse
44
import stock
55

6-
class Portfolio(object):
6+
class Portfolio:
77
def __init__(self):
88
self._holdings = []
99

Solutions/8_1/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typedproperty import String, Integer, Float
44

5-
class Stock(object):
5+
class Stock:
66
'''
77
An instance of a stock holding consisting of name, shares, and price.
88
'''

Solutions/8_1/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/8_1/typedproperty.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def prop(self, value):
2020

2121
# Example
2222
if __name__ == '__main__':
23-
class Stock(object):
23+
class Stock:
2424
name = typedproperty('name', str)
2525
shares = typedproperty('shares', int)
2626
price = typedproperty('price', float)

Solutions/8_2/portfolio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import fileparse
44
import stock
55

6-
class Portfolio(object):
6+
class Portfolio:
77
def __init__(self):
88
self._holdings = []
99

Solutions/8_2/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typedproperty import String, Integer, Float
44

5-
class Stock(object):
5+
class Stock:
66
'''
77
An instance of a stock holding consisting of name, shares, and price.
88
'''

Solutions/8_2/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/8_2/typedproperty.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def prop(self, value):
2020

2121
# Example
2222
if __name__ == '__main__':
23-
class Stock(object):
23+
class Stock:
2424
name = typedproperty('name', str)
2525
shares = typedproperty('shares', int)
2626
price = typedproperty('price', float)

Solutions/9_3/porty-app/porty/portfolio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from . import fileparse
44
from . import stock
55

6-
class Portfolio(object):
6+
class Portfolio:
77
def __init__(self):
88
self._holdings = []
99

Solutions/9_3/porty-app/porty/stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from .typedproperty import String, Integer, Float
44

5-
class Stock(object):
5+
class Stock:
66
'''
77
An instance of a stock holding consisting of name, shares, and price.
88
'''

Solutions/9_3/porty-app/porty/tableformat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# tableformat.py
22

3-
class TableFormatter(object):
3+
class TableFormatter:
44
def headings(self, headers):
55
'''
66
Emit the table headers

Solutions/9_3/porty-app/porty/typedproperty.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def prop(self, value):
2020

2121
# Example
2222
if __name__ == '__main__':
23-
class Stock(object):
23+
class Stock:
2424
name = typedproperty('name', str)
2525
shares = typedproperty('shares', int)
2626
price = typedproperty('price', float)

Solutions/9_5/porty-app/MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include *.csv

Solutions/9_5/porty-app/README.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Code from Practical Python.
2+
3+
The "porty" directory is a Python package of code that's loaded via
4+
import. The "print-report.py" program is a top-level script that
5+
produces a report. Try it:
6+
7+
shell % python3 print-report.py portfolio.csv prices.csv txt
8+
Name Shares Price Change
9+
---------- ---------- ---------- ----------
10+
AA 100 9.22 -22.98
11+
IBM 50 106.28 15.18
12+
CAT 150 35.46 -47.98
13+
MSFT 200 20.89 -30.34
14+
GE 95 13.48 -26.89
15+
MSFT 50 20.89 -44.21
16+
IBM 100 106.28 35.84
17+
shell %

Solutions/9_5/porty-app/portfolio.csv

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name,shares,price
2+
"AA",100,32.20
3+
"IBM",50,91.10
4+
"CAT",150,83.44
5+
"MSFT",200,51.23
6+
"GE",95,40.37
7+
"MSFT",50,65.10
8+
"IBM",100,70.44

Solutions/9_5/porty-app/porty/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)