Skip to content

Commit f61504c

Browse files
committed
Add output to bottom of scripts
1 parent ec8d735 commit f61504c

29 files changed

+304
-0
lines changed

3-tier.py

+14
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,17 @@ def main():
5656

5757
if __name__ == '__main__':
5858
main()
59+
60+
### OUTPUT ###
61+
# PRODUCT LIST:
62+
# eggs
63+
# milk
64+
# cheese
65+
#
66+
# PRODUCT INFORMATION:
67+
# Name: Cheese, Price: 2.00, Quantity: 10
68+
# PRODUCT INFORMATION:
69+
# Name: Eggs, Price: 0.20, Quantity: 100
70+
# PRODUCT INFORMATION:
71+
# Name: Milk, Price: 1.50, Quantity: 10
72+
# That product "arepas" does not exist in the records

abstract_factory.py

+14
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,17 @@ def get_factory():
7676
shop.pet_factory = get_factory()
7777
shop.show_pet()
7878
print("=" * 20)
79+
80+
### OUTPUT ###
81+
# This is a lovely Dog
82+
# It says woof
83+
# It eats dog food
84+
# ====================
85+
# This is a lovely Cat
86+
# It says meow
87+
# It eats cat food
88+
# ====================
89+
# This is a lovely Dog
90+
# It says woof
91+
# It eats dog food
92+
# ====================

adapter.py

+3
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,6 @@ def main():
9191
if __name__ == "__main__":
9292
import doctest
9393
doctest.testmod()
94+
95+
### OUTPUT ###
96+

borg.py

+11
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@ class YourBorg(Borg):
3838
print('rm1: {0}'.format(rm1))
3939
print('rm2: {0}'.format(rm2))
4040
print('rm3: {0}'.format(rm3))
41+
42+
### OUTPUT ###
43+
# rm1: Running
44+
# rm2: Running
45+
# rm1: Zombie
46+
# rm2: Zombie
47+
# rm1 id: 139825262601040
48+
# rm2 id: 139825262601104
49+
# rm1: Zombie
50+
# rm2: Zombie
51+
# rm3: Zombie

bridge.py

+4
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ def main():
4646

4747
if __name__ == '__main__':
4848
main()
49+
50+
### OUTPUT ###
51+
# API1.circle at 1:2 radius 7.5
52+
# API2.circle at 5:7 radius 27.5

builder.py

+4
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ def __repr__(self):
6868
director.construct_building()
6969
building = director.get_building()
7070
print(building)
71+
72+
### OUTPUT ###
73+
# Floor: One | Size: Big
74+
# Floor: More than One | Size: Small

catalog.py

+3
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ def main():
5858

5959
if __name__ == "__main__":
6060
main()
61+
62+
### OUTPUT ###
63+
# executed method 2!

chain.py

+11
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,14 @@ def delegate(self, requests):
5353
client = Client()
5454
requests = [2, 5, 14, 22, 18, 3, 35, 27, 20]
5555
client.delegate(requests)
56+
57+
### OUTPUT ###
58+
# request 2 handled in handler 1
59+
# request 5 handled in handler 1
60+
# request 14 handled in handler 2
61+
# request 22 handled in handler 3
62+
# request 18 handled in handler 2
63+
# request 3 handled in handler 1
64+
# end of chain, no handler for 35
65+
# request 27 handled in handler 3
66+
# request 20 handled in handler 2

command.py

+6
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ def main():
3838

3939
if __name__ == "__main__":
4040
main()
41+
42+
### OUTPUT ###
43+
# renaming foo.txt to bar.txt
44+
# renaming bar.txt to baz.txt
45+
# renaming baz.txt to bar.txt
46+
# renaming bar.txt to foo.txt

composite.py

+4
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,7 @@ def addChild2(self, child):
332332
# print(window.Frame.Button2)
333333
print(window.Frame.Button1.label)
334334
print(window.Frame.Button2.label)
335+
336+
### OUTPUT ###
337+
# Submit
338+
# Browse

decorator.py

+5
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,8 @@ def main():
4545

4646
if __name__ == '__main__':
4747
main()
48+
49+
### OUTPUT ###
50+
# decorated f1
51+
# original f1
52+
# original f2

facade.py

+20
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,23 @@ def runAll(self):
6161
if __name__ == '__main__':
6262
testrunner = TestRunner()
6363
testrunner.runAll()
64+
65+
### OUTPUT ###
66+
# ###### In Test 1 ######
67+
# Setting up
68+
# Running test
69+
# Tearing down
70+
# Test Finished
71+
#
72+
# ###### In Test 2 ######
73+
# Setting up
74+
# Running test
75+
# Tearing down
76+
# Test Finished
77+
#
78+
# ###### In Test 3 ######
79+
# Setting up
80+
# Running test
81+
# Tearing down
82+
# Test Finished
83+
#

factory_method.py

+6
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ def get_localizer(language="English"):
3333
# Localize some text
3434
for msgid in "dog parrot cat bear".split():
3535
print(e.get(msgid), g.get(msgid))
36+
37+
### OUTPUT ###
38+
# dog σκύλος
39+
# parrot parrot
40+
# cat γάτα
41+
# bear bear

flyweight.py

+5
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ def __repr__(self):
3434
print(c1, c2)
3535
print(c1 == c2)
3636
print(id(c1), id(c2))
37+
38+
### OUTPUT ###
39+
# <Card: 9h> <Card: 9h>
40+
# True
41+
# 140368617673296 140368617673296

graph_search.py

+5
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,8 @@ def find_shortest_path(self, start, end, path=[]):
7878
print(graph1.find_path('A', 'D'))
7979
print(graph1.find_all_path('A', 'D'))
8080
print(graph1.find_shortest_path('A', 'D'))
81+
82+
### OUTPUT ###
83+
# ['A', 'B', 'C', 'D']
84+
# [['A', 'B', 'C', 'D']]
85+
# ['A', 'B', 'C', 'D']

iterator.py

+6
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ def count_to(count):
2929
print(number, end=' ')
3030

3131
print()
32+
33+
### OUTPUT ###
34+
# Counting to two...
35+
# one two
36+
# Counting to five...
37+
# one two three four five

mediator.py

+19
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,22 @@ def setTC(self, tc):
118118
tc.setup()
119119
tc.execute()
120120
tc.tearDown()
121+
122+
### OUTPUT ###
123+
# Setting up the Test
124+
# Inserting the execution begin status in the Database
125+
# Executing the test
126+
# Tearing down
127+
# Updating the test results in Database
128+
# Reporting the results of Test
129+
# Setting up the Test
130+
# Inserting the execution begin status in the Database
131+
# Reporter Class is preparing to report the results
132+
# Problem in setup. Test not executed.
133+
# Test not executed. No tear down required.
134+
# Setting up the Test
135+
# Inserting the execution begin status in the Database
136+
# Executing the test
137+
# Tearing down
138+
# Updating the test results in Database
139+
# Reporting the results of Test

memento.py

+25
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,28 @@ def DoStuff(self):
9595
traceback.print_exc(file=sys.stdout)
9696
pass
9797
print(n)
98+
99+
### OUTPUT ###
100+
# <NumObj: -1>
101+
# <NumObj: 0>
102+
# <NumObj: 1>
103+
# <NumObj: 2>
104+
# -- commited
105+
# <NumObj: 3>
106+
# <NumObj: 4>
107+
# <NumObj: 5>
108+
# -- rolled back
109+
# <NumObj: 2>
110+
# -- now doing stuff ...
111+
# -> doing stuff failed!
112+
# Traceback (most recent call last):
113+
# File "memento.py", line 91, in <module>
114+
# n.DoStuff()
115+
# File "memento.py", line 47, in transaction
116+
# return self.method(obj, *args, **kwargs)
117+
# File "memento.py", line 67, in DoStuff
118+
# self.Increment() # <- will fail and rollback
119+
# File "memento.py", line 62, in Increment
120+
# self.value += 1
121+
# TypeError: Can't convert 'int' object to str implicitly
122+
# <NumObj: 2>

mvc.py

+17
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,20 @@ def get_product_information(self, product):
5555
controller.get_product_information('eggs')
5656
controller.get_product_information('milk')
5757
controller.get_product_information('arepas')
58+
59+
### OUTPUT ###
60+
# PRODUCT LIST:
61+
# cheese
62+
# eggs
63+
# milk
64+
#
65+
# PRODUCT INFORMATION:
66+
# Name: Cheese, Price: 2.00, Quantity: 10
67+
#
68+
# PRODUCT INFORMATION:
69+
# Name: Eggs, Price: 0.20, Quantity: 100
70+
#
71+
# PRODUCT INFORMATION:
72+
# Name: Milk, Price: 1.50, Quantity: 10
73+
#
74+
# That product "arepas" does not exist in the records

null.py

+7
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,10 @@ def test():
8080

8181
if __name__ == '__main__':
8282
test()
83+
84+
### OUTPUT ###
85+
# Null
86+
# Null
87+
# Null
88+
# Null
89+
# attr1 Null

observer.py

+19
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,22 @@ def main():
8383

8484
if __name__ == '__main__':
8585
main()
86+
87+
### OUTPUT ###
88+
# Setting Data 1 = 10
89+
# DecimalViewer: Subject Data 1 has data 10
90+
# HexViewer: Subject Data 1 has data 0xa
91+
# Setting Data 2 = 15
92+
# HexViewer: Subject Data 2 has data 0xf
93+
# DecimalViewer: Subject Data 2 has data 15
94+
# Setting Data 1 = 3
95+
# DecimalViewer: Subject Data 1 has data 3
96+
# HexViewer: Subject Data 1 has data 0x3
97+
# Setting Data 2 = 5
98+
# HexViewer: Subject Data 2 has data 0x5
99+
# DecimalViewer: Subject Data 2 has data 5
100+
# Detach HexViewer from data1 and data2.
101+
# Setting Data 1 = 10
102+
# DecimalViewer: Subject Data 1 has data 10
103+
# Setting Data 2 = 15
104+
# DecimalViewer: Subject Data 2 has data 15

pool.py

+6
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ def test_object(queue):
5252

5353
if __name__ == '__main__':
5454
main()
55+
56+
### OUTPUT ###
57+
# Inside with: yam
58+
# Outside with: yam
59+
# Inside func: sam
60+
# Outside func: sam

prototype.py

+4
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ class A:
3838

3939
if __name__ == '__main__':
4040
main()
41+
42+
### OUTPUT ###
43+
# <__main__.main.<locals>.A object at 0x7fc1d23272d0>
44+
# 1 2 3

proxy.py

+6
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ def work(self):
3333
p.work()
3434
p.busy = 'Yes'
3535
p.work()
36+
37+
### OUTPUT ###
38+
# Proxy checking for Sales Manager availability
39+
# Sales Manager ready to talk
40+
# Proxy checking for Sales Manager availability
41+
# Sales Manager is busy

publish_subscribe.py

+8
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,11 @@ def main():
7979

8080
if __name__ == "__main__":
8181
main()
82+
83+
### OUTPUT ###
84+
# jim got cartoon
85+
# jack got music
86+
# gee got movie
87+
# jim got cartoon
88+
# jim got cartoon
89+
# gee got movie

state.py

+12
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,15 @@ def scan(self):
6161

6262
for action in actions:
6363
action()
64+
65+
### OUTPUT ###
66+
# Scanning... Station is 1380 AM
67+
# Scanning... Station is 1510 AM
68+
# Switching to FM
69+
# Scanning... Station is 89.1 FM
70+
# Scanning... Station is 103.9 FM
71+
# Scanning... Station is 81.3 FM
72+
# Scanning... Station is 89.1 FM
73+
# Switching to AM
74+
# Scanning... Station is 1250 AM
75+
# Scanning... Station is 1380 AM

strategy.py

+5
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ def execute_replacement2(self):
4141
strat0.execute()
4242
strat1.execute()
4343
strat2.execute()
44+
45+
### OUTPUT ###
46+
# Strategy Example 0
47+
# Strategy Example 1 from execute 1
48+
# Strategy Example 2 from execute 2

0 commit comments

Comments
 (0)