Archive:Think Python/Classes and functions: Difference between revisions
wikademia>Whiteknight m Partial (mostly) conversion from HTML to Wikitext |
|||
| Line 1: | Line 1: | ||
{{Think Python/Page}} | {{Think Python/Page}} | ||
== Chapter | == Chapter 16 Classes and functions == | ||
=== 16.1 | === 16.1 Time === | ||
As another example of a user-defined type, we | As another example of a user-defined type, we'll define a class called | ||
<TT>Time</TT> that records the time of day. The class definition looks | <TT>Time</TT> that records the time of day. The class definition looks | ||
like this: | like this: | ||
<PRE CLASS="verbatim">class Time(object): | <PRE CLASS="verbatim">class Time(object): | ||
| Line 27: | Line 23: | ||
</PRE> | </PRE> | ||
The state diagram for the <TT>Time</TT> object looks like this: | The state diagram for the <TT>Time</TT> object looks like this: | ||