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 16  Classes and functions ==
== Chapter 16 Classes and functions ==






=== 16.1  Time ===
=== 16.1 Time ===


As another example of a user-defined type, we’ll define a class called
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: