📄 page586.html
字号:
<HTML><HEAD><TITLE>Objects and Types</TITLE></HEAD><BODY bgcolor="#FFFFFF"> <a href="../index.html" target="_top"><img src="../icons/usins.gif" alt="Logo" align=right></a><b>Data Structures and Algorithms with Object-Oriented Design Patterns in Python</b><br><A NAME="tex2html7887" HREF="page587.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html7885" HREF="page585.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html7879" HREF="page585.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html7889" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H1><A NAME="SECTION0017100000000000000000">Objects and Types</A></H1><P>An <em>object</em><A NAME=56830> </A> is a programming language abstractionthat represents a storage location.A Python object has the following <em>attributes</em>:<DL ><DT><STRONG>type</STRONG><DD> The <em>type</em><A NAME=56834> </A> of an object determines the set of values that the object can have <em>and</em> the set of operations that can be performed on that object. <DT><STRONG>value</STRONG><DD> The <em>value</em><A NAME=56837> </A> of an object is the content of the memory location(s) occupied by that variable. How the contents of the memory locations are interpreted is determined by the <em>type</em> of the variable. <DT><STRONG>lifetime</STRONG><DD> The <em>lifetime</em><A NAME=56840> </A> of an object is the interval of time in the execution of a Python program during which the object is said to exist.<P> </DL><P>Python defines an extensive type hierarchy.This hierarchy includesthe numeric types (such as <tt>int</tt>, <tt>float</tt> and <tt>complex</tt>),sequences (such as <tt>tuple</tt> and <tt>list</tt>),functions (type <tt>function</tt>),classes and methods (types <tt>classobj</tt> and <tt>instancemethod</tt>), andand instances of classes (type <tt>instance</tt>).<P><HR><A NAME="tex2html7887" HREF="page587.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html7885" HREF="page585.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html7879" HREF="page585.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html7889" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <P><ADDRESS><img src="../icons/bruno.gif" alt="Bruno" align=right><a href="../copyright.html">Copyright © 2003</a> by <a href="../signature.html">Bruno R. Preiss, P.Eng.</a> All rights reserved.</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -