class
Book:
def
__init__(
self
, title, author, pages, status
=
'want to read'
):
self
.title
=
title
self
.author
=
author
self
.pages
=
pages
self
.status
=
status
def
is_long(
self
):
return
self
.pages>
=
500
def
is_long_descr(
self
):
if
self
.pages>
=
500
:
return
'{} is long book'
.
format
(
self
.title)
else
:
return
'{} is not long book'
.
format
(
self
.title)
def
mark_reading(
self
):
print
'Start reading book {}'
.
format
(
self
.title)
self
.status
=
'currently reading'
def
mark_complete(
self
):
print
'Finish reading book {}'
.
format
(
self
.title)
self
.status
=
'completed'
def
__str__(
self
):
return
"{} by {}, # pages: {}, status: {}."
.
format
(
self
.title,
self
.author,
self
.pages,
self
.status)
my_book1
=
Book(title
=
'Alice in Wonderland'
, author
=
'Lewis Caroll'
, pages
=
92
)
my_book2
=
Book(title
=
'The Three Musketeers'
, author
=
'Alexandre Dumas'
, pages
=
786
, status
=
'currently reading'
)
my_books
=
(my_book1, my_book2)
for
book
in
my_books:
print
book
print
'Is long: {}'
.
format
(book.is_long())
print
book.is_long_descr()
if
book.status
not
in
(
'currently reading'
,
'completed'
):
book.mark_reading()
book.mark_complete()
print
book
print
'\n----------------\n'