May 2019
Beginner
528 pages
29h 51m
English
Let’s develop a Time class that stores the time in 24-hour clock format with hours in the range 0–23, and minutes and seconds each in the range 0–59. For this class, we’ll provide properties, which look like data attributes to client-code programmers, but control the manner in which they get and modify an object’s data. This assumes that other programmers follow Python conventions to correctly use objects of your class.
TimeBefore we look at class Time’s definition, let’s demonstrate its capabilities. First, ensure that you’re in the ch10 folder, then import class Time from timewithproperties.py:
In [1]: from timewithproperties import Time
Time ObjectNext, let’s create ...
Read now
Unlock full access