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

Skip to content

Commit 38f6b88

Browse files
committed
Elaborate the explanation of different flavors of _* identifiers.
Fixes SF bug #520325.
1 parent c0678ff commit 38f6b88

1 file changed

Lines changed: 30 additions & 16 deletions

File tree

Doc/ref/ref2.tex

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -320,25 +320,39 @@ \subsection{Keywords\label{keywords}}
320320
\subsection{Reserved classes of identifiers\label{id-classes}}
321321

322322
Certain classes of identifiers (besides keywords) have special
323-
meanings. These are:
323+
meanings. These classes are identified by the patterns of leading and
324+
trailing underscore characters:
324325

325-
\begin{tableiii}{l|l|l}{code}{Form}{Meaning}{Notes}
326-
\lineiii{_*}{Not imported by \samp{from \var{module} import *}}{(1)}
327-
\lineiii{__*__}{System-defined name}{}
328-
\lineiii{__*}{Class-private name mangling}{}
329-
\end{tableiii}
330-
331-
See sections: \ref{import}, ``The \keyword{import} statement'';
332-
\ref{specialnames}, ``Special method names'';
333-
\ref{atom-identifiers}, ``Identifiers (Names)''.
326+
\begin{description}
334327

335-
Note:
328+
\item[\code{_*}]
329+
Not imported by \samp{from \var{module} import *}. The special
330+
identifier \samp{_} is used in the interactive interpreter to store
331+
the result of the last evaluation; it is stored in the
332+
\module{__builtin__} module. When not in interactive mode, \samp{_}
333+
has no special meaning and is not defined.
334+
See section~\ref{import}, ``The \keyword{import} statement.''
335+
336+
\note{The name \samp{_} is often used in conjunction with
337+
internationalization; refer to the documentation for the
338+
\ulink{\module{gettext} module}{../lib/module-gettext.html} for more
339+
information on this convention.}
340+
341+
\item[\code{__*__}]
342+
System-defined names. These names are defined by the interpreter
343+
and it's implementation (including the standard library);
344+
applications should not expect to define additional names using this
345+
convention. The set of names of this class defined by Python may be
346+
extended in future versions.
347+
See section~\ref{specialnames}, ``Special method names.''
348+
349+
\item[\code{__*}]
350+
Class-private names. Names in this category, when used within the
351+
context of a class definition, are re-written to use a mangled for
352+
to help avoid name clashes between ``private'' attributes of base
353+
and derived classes.
354+
See section~\ref{atom-identifiers}, ``Identifiers (Names).''
336355

337-
\begin{description}
338-
\item[(1)] The special identifier \samp{_} is used in the interactive
339-
interpreter to store the result of the last evaluation; it is stored
340-
in the \module{__builtin__} module. When not in interactive mode,
341-
\samp{_} has no special meaning and is not defined.
342356
\end{description}
343357

344358

0 commit comments

Comments
 (0)