Skip to content

Commit 5ea6ac1

Browse files
committed
Removing (object) from class defs
1 parent fb28032 commit 5ea6ac1

16 files changed

+26
-19
lines changed

code/BadKangaroo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
"""
2121

22-
class Kangaroo(object):
22+
class Kangaroo:
2323
"""A Kangaroo is a marsupial."""
2424

2525
def __init__(self, name, contents=[]):

code/Card.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import random
1515

1616

17-
class Card(object):
17+
class Card:
1818
"""Represents a standard playing card.
1919
2020
Attributes:
@@ -45,7 +45,7 @@ def __lt__(self, other):
4545
return t1 < t2
4646

4747

48-
class Deck(object):
48+
class Deck:
4949
"""Represents a deck of cards.
5050
5151
Attributes:

code/Circle.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from Point1_soln import distance_between_points
1818

1919

20-
class Circle(object):
20+
class Circle:
2121
"""Represents a circle.
2222
2323
Attributes: center, radius
@@ -106,7 +106,7 @@ def main():
106106

107107
circle = Circle
108108
circle.center = Point()
109-
circle.center.x = 100.0
109+
circle.center.x = 150.0
110110
circle.center.y = 100.0
111111
circle.radius = 75.0
112112

code/GoodKangaroo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
"""
2121

22-
class Kangaroo(object):
22+
class Kangaroo:
2323
"""A Kangaroo is a marsupial."""
2424

2525
def __init__(self, name, contents=[]):

code/Map.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from __future__ import print_function, division
1313

1414

15-
class LinearMap(object):
15+
class LinearMap:
1616
"""A simple implementation of a map using a list of tuples
1717
where each tuple is a key-value pair."""
1818

@@ -33,7 +33,7 @@ def get(self, k):
3333
raise KeyError
3434

3535

36-
class BetterMap(object):
36+
class BetterMap:
3737
"""A faster implementation of a map using a list of LinearMaps
3838
and the built-in function hash() to determine which LinearMap
3939
to put each key into."""
@@ -60,7 +60,7 @@ def get(self, k):
6060
return m.get(k)
6161

6262

63-
class HashMap(object):
63+
class HashMap:
6464
"""An implementation of a hashtable using a BetterMap
6565
that grows so that the number of items never exceeds the number
6666
of LinearMaps.

code/Markov.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from markov import skip_gutenberg_header, shift
1919

2020

21-
class Markov(object):
21+
class Markov:
2222
"""Encapsulates the statistical summary of a text."""
2323

2424
def __init__(self):

code/Point1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from __future__ import print_function, division
1313

1414

15-
class Point(object):
15+
class Point:
1616
"""Represents a point in 2-D space.
1717
1818
attributes: x, y
@@ -24,7 +24,7 @@ def print_point(p):
2424
print('(%g, %g)' % (p.x, p.y))
2525

2626

27-
class Rectangle(object):
27+
class Rectangle:
2828
"""Represents a rectangle.
2929
3030
attributes: width, height, corner.

code/Point2_soln.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from __future__ import print_function, division
1313

1414

15-
class Point(object):
15+
class Point:
1616
"""Represents a point in 2-D space.
1717
1818
attributes: x, y

code/Time1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from __future__ import print_function, division
1313

1414

15-
class Time(object):
15+
class Time:
1616
"""Represents the time of day.
1717
1818
attributes: hour, minute, second

code/Time2.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from __future__ import print_function, division
1313

1414

15-
class Time(object):
15+
class Time:
1616
"""Represents the time of day.
1717
1818
attributes: hour, minute, second
@@ -96,6 +96,7 @@ def main():
9696
start.print_time()
9797

9898
end = start.increment(1337)
99+
#end = start.increment(1337, 460)
99100
end.print_time()
100101

101102
print('Is end after start?')

code/Time2_soln.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from __future__ import print_function, division
1313

1414

15-
class Time(object):
15+
class Time:
1616
"""Represents the time of day.
1717
1818
attributes: hour, minute, second

code/find_duplicates.py

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def walk(dirname):
2020
dirname: string name of directory
2121
"""
2222
names = []
23+
if '__pycache__' in dirname:
24+
return names
25+
2326
for name in os.listdir(dirname):
2427
path = os.path.join(dirname, name)
2528

code/find_duplicates_copy.py

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def walk(dirname):
2020
dirname: string name of directory
2121
"""
2222
names = []
23+
if '__pycache__' in dirname:
24+
return names
25+
2326
for name in os.listdir(dirname):
2427
path = os.path.join(dirname, name)
2528

code/polygon.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def circle(t, r):
8787
# draw a circle centered on the origin
8888
radius = 100
8989
bob.pu()
90-
bob.fd( radius)
90+
bob.fd(radius)
9191
bob.lt(90)
9292
bob.pd()
9393
circle(bob, radius)

code/reducible.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def make_word_dict():
1818
fin = open('words.txt')
1919
for line in fin:
2020
word = line.strip().lower()
21-
d[word] = word
21+
d[word] = None
2222

2323
# have to add single letter words to the word list;
2424
# also, the empty string is considered a word.

code/rotate_pairs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def make_word_dict():
2121
fin = open('words.txt')
2222
for line in fin:
2323
word = line.strip().lower()
24-
d[word] = word
24+
d[word] = None
2525

2626
return d
2727

0 commit comments

Comments
 (0)