home *** CD-ROM | disk | FTP | other *** search
- <TITLE>types -- Python library reference</TITLE>
- Next: <A HREF="../t/traceback" TYPE="Next">traceback</A>
- Prev: <A HREF="../s/sys" TYPE="Prev">sys</A>
- Up: <A HREF="../p/python_services" TYPE="Up">Python Services</A>
- Top: <A HREF="../t/top" TYPE="Top">Top</A>
- <H1>3.2. Standard Module <CODE>types</CODE></H1>
- This module defines names for all object types that are used by the
- standard Python interpreter (but not for the types defined by various
- extension modules). It is safe to use ``<CODE>from types import *</CODE>'' ---
- the module does not export any other names besides the ones listed
- here. New names exported by future versions of this module will
- all end in <CODE>Type</CODE>.
- <P>
- Typical use is for functions that do different things depending on
- their argument types, like the following:
- <P>
- <UL COMPACT><CODE>from types import *<P>
- def delete(list, item):<P>
- if type(item) is IntType:<P>
- del list[item]<P>
- else:<P>
- list.remove(item)<P>
- </CODE></UL>
- The module defines the following names:
- <P>
- <DL><DT><B>NoneType</B> -- data of module types<DD>
- The type of <CODE>None</CODE>.
- </DL>
- <DL><DT><B>TypeType</B> -- data of module types<DD>
- The type of type objects (such as returned by <CODE>type()</CODE>).
- </DL>
- <DL><DT><B>IntType</B> -- data of module types<DD>
- The type of integers (e.g. <CODE>1</CODE>).
- </DL>
- <DL><DT><B>LongType</B> -- data of module types<DD>
- The type of long integers (e.g. <CODE>1L</CODE>).
- </DL>
- <DL><DT><B>FloatType</B> -- data of module types<DD>
- The type of floating point numbers (e.g. <CODE>1.0</CODE>).
- </DL>
- <DL><DT><B>StringType</B> -- data of module types<DD>
- The type of character strings (e.g. <CODE>'Spam'</CODE>).
- </DL>
- <DL><DT><B>TupleType</B> -- data of module types<DD>
- The type of tuples (e.g. <CODE>(1, 2, 3, 'Spam')</CODE>).
- </DL>
- <DL><DT><B>ListType</B> -- data of module types<DD>
- The type of lists (e.g. <CODE>[0, 1, 2, 3]</CODE>).
- </DL>
- <DL><DT><B>DictType</B> -- data of module types<DD>
- The type of dictionaries (e.g. <CODE>{'Bacon': 1, 'Ham': 0}</CODE>).
- </DL>
- <DL><DT><B>DictionaryType</B> -- data of module types<DD>
- An alternative name for <CODE>DictType</CODE>.
- </DL>
- <DL><DT><B>FunctionType</B> -- data of module types<DD>
- The type of user-defined functions and lambdas.
- </DL>
- <DL><DT><B>LambdaType</B> -- data of module types<DD>
- An alternative name for <CODE>FunctionType</CODE>.
- </DL>
- <DL><DT><B>CodeType</B> -- data of module types<DD>
- The type for code objects such as returned by <CODE>compile()</CODE>.
- </DL>
- <DL><DT><B>ClassType</B> -- data of module types<DD>
- The type of user-defined classes.
- </DL>
- <DL><DT><B>InstanceType</B> -- data of module types<DD>
- The type of instances of user-defined classes.
- </DL>
- <DL><DT><B>MethodType</B> -- data of module types<DD>
- The type of methods of user-defined class instances.
- </DL>
- <DL><DT><B>UnboundMethodType</B> -- data of module types<DD>
- An alternative name for <CODE>MethodType</CODE>.
- </DL>
- <DL><DT><B>BuiltinFunctionType</B> -- data of module types<DD>
- The type of built-in functions like <CODE>len</CODE> or <CODE>sys.exit</CODE>.
- </DL>
- <DL><DT><B>BuiltinMethodType</B> -- data of module types<DD>
- An alternative name for <CODE>BuiltinFunction</CODE>.
- </DL>
- <DL><DT><B>ModuleType</B> -- data of module types<DD>
- The type of modules.
- </DL>
- <DL><DT><B>FileType</B> -- data of module types<DD>
- The type of open file objects such as <CODE>sys.stdout</CODE>.
- </DL>
- <DL><DT><B>XRangeType</B> -- data of module types<DD>
- The type of range objects returned by <CODE>xrange()</CODE>.
- </DL>
- <DL><DT><B>TracebackType</B> -- data of module types<DD>
- The type of traceback objects such as found in <CODE>sys.exc_traceback</CODE>.
- </DL>
- <DL><DT><B>FrameType</B> -- data of module types<DD>
- The type of frame objects such as found in <CODE>tb.tb_frame</CODE> if
- <CODE>tb</CODE> is a traceback object.
- </DL>
-