-\section{Built-in Types \label{types}}
+\chapter{Built-in Types \label{types}}
The following sections describe the standard types that are built into
the interpreter.
\citetitle[../tut/tut.html]{Python Tutorial}.)
-\subsection{Truth Value Testing\label{truth}}
+\section{Truth Value Testing\label{truth}}
Any object can be tested for truth value, for use in an \keyword{if} or
\keyword{while} condition or as operand of the Boolean operations below.
\index{False}
\index{True}
-\subsection{Boolean Operations ---
+\section{Boolean Operations ---
\keyword{and}, \keyword{or}, \keyword{not}
\label{boolean}}
\end{description}
-\subsection{Comparisons \label{comparisons}}
+\section{Comparisons \label{comparisons}}
Comparison operations are supported by all objects. They all have the
same priority (which is higher than that of the Boolean operations).
only by sequence types (below).
-\subsection{Numeric Types ---
+\section{Numeric Types ---
\class{int}, \class{float}, \class{long}, \class{complex}
\label{typesnumeric}}
\end{description}
% XXXJH exceptions: overflow (when? what operations?) zerodivision
-\subsubsection{Bit-string Operations on Integer Types \label{bitstring-ops}}
+\subsection{Bit-string Operations on Integer Types \label{bitstring-ops}}
\nodename{Bit-string Operations}
Plain and long integer types support additional operations that make
\end{description}
-\subsection{Iterator Types \label{typeiter}}
+\section{Iterator Types \label{typeiter}}
\versionadded{2.2}
\index{iterator protocol}
supplying the \method{__iter__()} and \method{next()} methods.
-\subsection{Sequence Types ---
+\section{Sequence Types ---
\class{str}, \class{unicode}, \class{list},
\class{tuple}, \class{buffer}, \class{xrange}
\label{typesseq}}
\end{description}
-\subsubsection{String Methods \label{string-methods}}
+\subsection{String Methods \label{string-methods}}
\indexii{string}{methods}
These are the string methods which both 8-bit strings and Unicode
\end{methoddesc}
-\subsubsection{String Formatting Operations \label{typesseq-strings}}
+\subsection{String Formatting Operations \label{typesseq-strings}}
\index{formatting, string (\%{})}
\index{interpolation, string (\%{})}
\refmodule{re}.\refstmodindex{re}
-\subsubsection{XRange Type \label{typesseq-xrange}}
+\subsection{XRange Type \label{typesseq-xrange}}
The \class{xrange}\obindex{xrange} type is an immutable sequence which
is commonly used for looping. The advantage of the \class{xrange}
iteration, and the \function{len()} function.
-\subsubsection{Mutable Sequence Types \label{typesseq-mutable}}
+\subsection{Mutable Sequence Types \label{typesseq-mutable}}
List objects support additional operations that allow in-place
modification of the object.
that the list has been mutated during a sort.
\end{description}
-\subsection{Set Types ---
+\section{Set Types ---
\class{set}, \class{frozenset}
\label{types-set}}
\obindex{set}
\end{seealso}
-\subsection{Mapping Types --- \class{dict} \label{typesmapping}}
+\section{Mapping Types --- \class{dict} \label{typesmapping}}
\obindex{mapping}
\obindex{dictionary}
\end{description}
-\subsection{File Objects
+\section{File Objects
\label{bltin-file-objects}}
File objects\obindex{file} are implemented using C's \code{stdio}
\end{memberdesc}
-\subsection{Context Manager Types \label{typecontextmanager}}
+\section{Context Manager Types \label{typecontextmanager}}
\versionadded{2.5}
\index{context manager}
is negligible.
-\subsection{Other Built-in Types \label{typesother}}
+\section{Other Built-in Types \label{typesother}}
The interpreter supports several other kinds of objects.
Most of these support only one or two operations.
-\subsubsection{Modules \label{typesmodules}}
+\subsection{Modules \label{typesmodules}}
The only special operation on a module is attribute access:
\code{\var{m}.\var{name}}, where \var{m} is a module and \var{name}
'/usr/local/lib/python\shortversion/os.pyc'>}.
-\subsubsection{Classes and Class Instances \label{typesobjects}}
+\subsection{Classes and Class Instances \label{typesobjects}}
\nodename{Classes and Instances}
See chapters 3 and 7 of the \citetitle[../ref/ref.html]{Python
Reference Manual} for these.
-\subsubsection{Functions \label{typesfunctions}}
+\subsection{Functions \label{typesfunctions}}
Function objects are created by function definitions. The only
operation on a function object is to call it:
See the \citetitle[../ref/ref.html]{Python Reference Manual} for more
information.
-\subsubsection{Methods \label{typesmethods}}
+\subsection{Methods \label{typesmethods}}
\obindex{method}
Methods are functions that are called using the attribute notation.
information.
-\subsubsection{Code Objects \label{bltin-code-objects}}
+\subsection{Code Objects \label{bltin-code-objects}}
\obindex{code}
Code objects are used by the implementation to represent
information.
-\subsubsection{Type Objects \label{bltin-type-objects}}
+\subsection{Type Objects \label{bltin-type-objects}}
Type objects represent the various object types. An object's type is
accessed by the built-in function \function{type()}. There are no special
Types are written like this: \code{<type 'int'>}.
-\subsubsection{The Null Object \label{bltin-null-object}}
+\subsection{The Null Object \label{bltin-null-object}}
This object is returned by functions that don't explicitly return a
value. It supports no special operations. There is exactly one null
It is written as \code{None}.
-\subsubsection{The Ellipsis Object \label{bltin-ellipsis-object}}
+\subsection{The Ellipsis Object \label{bltin-ellipsis-object}}
This object is used by extended slice notation (see the
\citetitle[../ref/ref.html]{Python Reference Manual}). It supports no
It is written as \code{Ellipsis}.
-\subsubsection{Boolean Values}
+\subsection{Boolean Values}
Boolean values are the two constant objects \code{False} and
\code{True}. They are used to represent truth values (although other
\indexii{Boolean}{values}
-\subsubsection{Internal Objects \label{typesinternal}}
+\subsection{Internal Objects \label{typesinternal}}
See the \citetitle[../ref/ref.html]{Python Reference Manual} for this
information. It describes stack frame objects, traceback objects, and
slice objects.
-\subsection{Special Attributes \label{specialattrs}}
+\section{Special Attributes \label{specialattrs}}
The implementation adds a few special read-only attributes to several
object types, where they are relevant. Some of these are not reported