📄 35.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Robots" content="INDEX,NOFOLLOW">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<TITLE>Safari | Python Essential Reference, Second Edition -> Terminology</TITLE>
<LINK REL="stylesheet" HREF="oreillyi/oreillyM.css">
</HEAD>
<BODY bgcolor="white" text="black" link="#990000" vlink="#990000" alink="#990000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellpadding=5 cellspacing=0 border=0 class="navtopbg"><tr><td><font size="1"><p class="navtitle"><a href="2.html" class="navtitle">Linux/Unix</a> > <a href="0735710910.html" class="navtitle">Python Essential Reference, Second Edition</a> > <a href="33.html" class="navtitle">3. Types and Objects</a> > <span class="nonavtitle">Terminology</span></p></font></td><td align="right" valign="top" nowrap><font size="1"><a href="main.asp?list" class="safnavoff">See All Titles</a></font></td></tr></table>
<TABLE width=100% bgcolor=white border=0 cellspacing=0 cellpadding=5><TR><TD>
<TABLE border=0 width="100%" cellspacing=0 cellpadding=0><TR><td align=left width="15%" class="headingsubbarbg"><a href="34.html" title="3. Types and Objects"><font size="1">< BACK</font></a></td><td align=center width="70%" class="headingsubbarbg"><font size="1"><a href="popanote.asp?pubui=oreilly&bookname=0735710910&snode=35" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="35.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="36.html" title="Object Identity and Type"><font size="1">CONTINUE ></font></a></td></TR></TABLE>
<a href="5%2F28%2F2002+8%3A54%3A06+PM.html" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><font color=white size=1>155117184014003188065099048180054212144238241179195140058238110137104028131048028205197128</font><a href="read1.asp?bookname=0735710910&snode=35&now=5%2F28%2F2002+8%3A54%3A06+PM" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><br>
<FONT>
<h3>Terminology</h3>
<p>Every piece of data stored in a program is an object. Each object has an identity, a type, and a value.</p>
<P>For example, when you write <TT Class="monofont">a = 42</TT>, an integer object is created with the value of <TT clasS="monofont">42</TT>. You can view the <I>identity</i> of an object as a pointer to its location in memory. In this example, <tt class="monofont">a</tt> is a name that refers to this specific location.</p>
<p>The <i>type</i> of an object (which is itself a special kind of object) describes the internal representation of the object as well as the methods and operations that it supports. When an object of a particular type is created, that object is sometimes called an <i>instance</i> of that type (although an instance of a type should not be confused with an instance of a user-defined class). After an object is created, its identity and type cannot be changed. If an object抯 value can be modified, the object is said to be <i>mutable</i>. If the value cannot be modified, the object is said to be <i>immutable</i>. An object that contains references to other objects is said to be a <I>container</i> or <i>collection</I>.</p>
<p>In addition to holding a value, many objects define a number of data attributes and methods. An <i>attribute</I> is a property or value associated with an object. A <i>method</i> is a function that performs some sort of operation on an object when the method is invoked. Attributes and methods are accessed using the dot (<tt ClasS="monofont">.</TT>) operator, as shown in the following example:</P>
<pre>
a = 3 + 4j # Create a complex number
r = a.real # Get the real part (an attribute)
b = [1, 2, 3] # Create a list
b.append(7) # Add a new element using the append method </pRE>
</FOnt>
<P><TABLE width="100%" border=0><TR valign="top"><TD><font size=1 color="#C0C0C0"><br></font></TD><TD align=right><font size=1 color="#C0C0C0">Last updated on 3/28/2002<br>Python Essential Reference, Second Edition, © 2002 New Riders Publishing</font></TD></TR></TABLE></P>
<TABLE border=0 width="100%" cellspacing=0 cellpadding=0><TR><td align=left width="15%" class="headingsubbarbg"><a href="34.html" title="3. Types and Objects"><font size="1">< BACK</font></a></td><td align=center width="70%" class="headingsubbarbg"><font size="1"><a href="popanote.asp?pubui=oreilly&bookname=0735710910&snode=35" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="35.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="36.html" title="Object Identity and Type"><font size="1">CONTINUE ></font></a></td></TR></TABLE>
</TD></TR></TABLE>
<!--EndOfBrowse-->
</TD></TR></TABLE>
<table width=100% border=0 cellspacing=0 cellpadding=0 bgcolor=#990000><tr><td><p align=center><font size=1 face="verdana,arial,helvetica" color=white>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -