Skip to content

Commit c34766d

Browse files
committed
book changes
1 parent 69a36b9 commit c34766d

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎python/book.py‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
class Book():
2-
favs = [] #class
2+
favs = []
33

44
def __init__(self, title, pages):
55
self.title = title
66
self.pages = pages
77

88
def is_short(self):
9-
if self.pages < 100:
10-
return True
9+
return self.pages < 100
1110

12-
#What happens when you pass object to print?
1311
def __str__(self):
1412
return f"{self.title}, {self.pages} pages long"
1513

16-
#What happens when you use ==?
1714
def __eq__(self, other):
18-
if(self.title == other.title and self.pages == other.pages):
19-
return True
15+
return self.title == other.title and self.pages == other.pages
16+
2017

21-
#It's appropriate to give something for __hash__ when you override __eq__
22-
# #This is the recommended way if mutable (like it is here):
2318
__hash__ = None
2419

2520
def __repr__(self): #added to make list of items invoke str

0 commit comments

Comments
 (0)