Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ec22f2

Browse files
committed
Another try at clarifying what goes into and comes out of Unicode objects.
Document the indices() method of slice objects.
1 parent 3e930ba commit 5ec22f2

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

Doc/ref/ref3.tex

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,19 @@ \section{The standard type hierarchy\label{types}}
305305
\bifuncindex{ord}
306306

307307
\item[Unicode]
308-
The items of a Unicode object are Unicode characters. A Unicode
309-
character is represented by a Unicode object of one item and can hold
310-
a 16-bit value representing a Unicode ordinal. The built-in functions
308+
The items of a Unicode object are Unicode code units. A Unicode code
309+
unit is represented by a Unicode object of one item and can hold
310+
either a 16-bit or 32-bit value representing a Unicode ordinal (the
311+
maximum value for the ordinal is given in \code{sys.maxunicode}, and
312+
depends on how Python is configured at compile time). Surrogate pairs
313+
may be present in the Unicode object, and will be reported as two
314+
separate items. The built-in functions
311315
\function{unichr()}\bifuncindex{unichr} and
312-
\function{ord()}\bifuncindex{ord} convert between characters and
316+
\function{ord()}\bifuncindex{ord} convert between code units and
313317
nonnegative integers representing the Unicode ordinals as defined in
314318
the Unicode Standard 3.0. Conversion from and to other encodings are
315319
possible through the Unicode method \method{encode} and the built-in
316-
function \function{unicode()}\bifuncindex{unicode}.
320+
function \function{unicode()}.\bifuncindex{unicode}
317321
\obindex{unicode}
318322
\index{character}
319323
\index{integer}
@@ -892,14 +896,18 @@ \section{The standard type hierarchy\label{types}}
892896
\ttindex{stop}
893897
\ttindex{step}}
894898

895-
Special method: \method{indices} takes an single integer argument
896-
\var{length} and computes information about the extended slice that
897-
the slice object would describe if applied to a sequence of
898-
\var{length}. It returns a tuple of three integers; respectively
899-
these are the \var{start} and \var{stop} indices and the \var{step} or
900-
stride length of the slice. Missing or out-of-bounds indices are
901-
handled in a manner consistent with regular slices.
899+
Slice objects support one method:
900+
901+
\begin{methoddesc}[slice]{indices}{self, length}
902+
This method takes a single integer argument \var{length} and computes
903+
information about the extended slice that the slice object would
904+
describe if applied to a sequence of \var{length} items. It returns a
905+
tuple of three integers; respectively these are the \var{start} and
906+
\var{stop} indices and the \var{step} or stride length of the slice.
907+
Missing or out-of-bounds indices are handled in a manner consistent
908+
with regular slices.
902909
\versionadded{2.3}
910+
\end{methoddesc}
903911

904912
\end{description} % Internal types
905913

0 commit comments

Comments
 (0)