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

Skip to content

Commit 3985df2

Browse files
committed
SF bug #660022: parameters for int(), str(), etc.
* Indicate that arguments are optional for most builtin type constructors. * Replace e.g. in staticmethod() and classmethod() docs. * Add \code{} markup to some in-line code examples.
1 parent 132fa37 commit 3985df2

1 file changed

Lines changed: 28 additions & 19 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ \section{Built-in Functions \label{built-in-funcs}}
8080
above.}
8181
\end{funcdesc}
8282

83-
\begin{funcdesc}{bool}{x}
83+
\begin{funcdesc}{bool}{\optional{x}}
8484
Convert a value to a Boolean, using the standard truth testing
8585
procedure. If \code{x} is false, this returns \code{False};
8686
otherwise it returns \code{True}. \code{bool} is also a class,
8787
which is a subclass of \code{int}. Class \code{bool} cannot be
8888
subclassed further. Its only instances are \code{False} and
89-
\code{True}.
89+
\code{True}. If no argument is given, this function returns
90+
\code{False}.
9091
\indexii{Boolean}{type}
9192
\versionadded{2.2.1}
9293
\end{funcdesc}
@@ -132,8 +133,9 @@ \section{Built-in Functions \label{built-in-funcs}}
132133
f = classmethod(f)
133134
\end{verbatim}
134135

135-
It can be called either on the class (e.g. C.f()) or on an instance
136-
(e.g. C().f()). The instance is ignored except for its class.
136+
It can be called either on the class (such as \code{C.f()}) or on an
137+
instance (such as \code{C().f()}). The instance is ignored except for
138+
its class.
137139
If a class method is called for a derived class, the derived class
138140
object is passed as the implied first argument.
139141

@@ -195,7 +197,7 @@ \section{Built-in Functions \label{built-in-funcs}}
195197
\module{__future__} module.
196198
\end{funcdesc}
197199

198-
\begin{funcdesc}{complex}{real\optional{, imag}}
200+
\begin{funcdesc}{complex}{\optional{real\optional{, imag}}}
199201
Create a complex number with the value \var{real} + \var{imag}*j or
200202
convert a string or number to a complex number. If the first
201203
parameter is a string, it will be interpreted as a complex number
@@ -204,7 +206,8 @@ \section{Built-in Functions \label{built-in-funcs}}
204206
Each argument may be any numeric type (including complex).
205207
If \var{imag} is omitted, it defaults to zero and the function
206208
serves as a numeric conversion function like \function{int()},
207-
\function{long()} and \function{float()}.
209+
\function{long()} and \function{float()}. If both arguments
210+
are omitted, returns \code{0j}.
208211
\end{funcdesc}
209212

210213
\begin{funcdesc}{delattr}{object, name}
@@ -447,14 +450,14 @@ \section{Built-in Functions \label{built-in-funcs}}
447450
None.
448451
\end{funcdesc}
449452

450-
\begin{funcdesc}{float}{x}
453+
\begin{funcdesc}{float}{\optional{x}}
451454
Convert a string or a number to floating point. If the argument is a
452455
string, it must contain a possibly signed decimal or floating point
453456
number, possibly embedded in whitespace; this behaves identical to
454457
\code{string.atof(\var{x})}. Otherwise, the argument may be a plain
455458
or long integer or a floating point number, and a floating point
456459
number with the same value (within Python's floating point
457-
precision) is returned.
460+
precision) is returned. If no argument is given, returns \code{0.0}.
458461

459462
\note{When passing in a string, values for NaN\index{NaN}
460463
and Infinity\index{Infinity} may be returned, depending on the
@@ -540,7 +543,7 @@ \section{Built-in Functions \label{built-in-funcs}}
540543
from users.
541544
\end{funcdesc}
542545

543-
\begin{funcdesc}{int}{x\optional{, radix}}
546+
\begin{funcdesc}{int}{\optional{x\optional{, radix}}}
544547
Convert a string or number to a plain integer. If the argument is a
545548
string, it must contain a possibly signed decimal number
546549
representable as a Python integer, possibly embedded in whitespace.
@@ -554,7 +557,7 @@ \section{Built-in Functions \label{built-in-funcs}}
554557
long integer or a floating point number. Conversion of floating
555558
point numbers to integers truncates (towards zero).
556559
If the argument is outside the integer range a long object will
557-
be returned instead.
560+
be returned instead. If no arguments are given, returns \code{0}.
558561
\end{funcdesc}
559562

560563
\begin{funcdesc}{intern}{string}
@@ -625,7 +628,8 @@ \section{Built-in Functions \label{built-in-funcs}}
625628
\var{sequence} is already a list, a copy is made and returned,
626629
similar to \code{\var{sequence}[:]}. For instance,
627630
\code{list('abc')} returns \code{['a', 'b', 'c']} and \code{list(
628-
(1, 2, 3) )} returns \code{[1, 2, 3]}.
631+
(1, 2, 3) )} returns \code{[1, 2, 3]}. If no argument is given,
632+
returns a new empty list, \code{[]}.
629633
\end{funcdesc}
630634

631635
\begin{funcdesc}{locals}{}
@@ -635,7 +639,7 @@ \section{Built-in Functions \label{built-in-funcs}}
635639
interpreter.}
636640
\end{funcdesc}
637641

638-
\begin{funcdesc}{long}{x\optional{, radix}}
642+
\begin{funcdesc}{long}{\optional{x\optional{, radix}}}
639643
Convert a string or number to a long integer. If the argument is a
640644
string, it must contain a possibly signed number of
641645
arbitrary size, possibly embedded in whitespace;
@@ -645,7 +649,8 @@ \section{Built-in Functions \label{built-in-funcs}}
645649
Otherwise, the argument may be a plain or
646650
long integer or a floating point number, and a long integer with
647651
the same value is returned. Conversion of floating
648-
point numbers to integers truncates (towards zero).
652+
point numbers to integers truncates (towards zero). If no arguments
653+
are given, returns \code{0L}.
649654
\end{funcdesc}
650655

651656
\begin{funcdesc}{map}{function, list, ...}
@@ -896,8 +901,9 @@ \section{Built-in Functions \label{built-in-funcs}}
896901
f = staticmethod(f)
897902
\end{verbatim}
898903

899-
It can be called either on the class (e.g. C.f()) or on an instance
900-
(e.g. C().f()). The instance is ignored except for its class.
904+
It can be called either on the class (such as \code{C.f()}) or on an
905+
instance (such as \code{C().f()}). The instance is ignored except
906+
for its class.
901907

902908
Static methods in Python are similar to those found in Java or C++.
903909
For a more advanced concept, see \ref{classmethod}.
@@ -929,13 +935,14 @@ \section{Built-in Functions \label{built-in-funcs}}
929935
\versionadded{2.2}
930936
\end{funcdesc}
931937

932-
\begin{funcdesc}{str}{object}
938+
\begin{funcdesc}{str}{\optional{object}}
933939
Return a string containing a nicely printable representation of an
934940
object. For strings, this returns the string itself. The
935941
difference with \code{repr(\var{object})} is that
936942
\code{str(\var{object})} does not always attempt to return a string
937943
that is acceptable to \function{eval()}; its goal is to return a
938-
printable string.
944+
printable string. If no argument is given, returns the empty
945+
string, \code{''}.
939946
\end{funcdesc}
940947

941948
\begin{funcdesc}{tuple}{\optional{sequence}}
@@ -945,7 +952,8 @@ \section{Built-in Functions \label{built-in-funcs}}
945952
If \var{sequence} is already a tuple, it
946953
is returned unchanged. For instance, \code{tuple('abc')} returns
947954
returns \code{('a', 'b', 'c')} and \code{tuple([1, 2, 3])} returns
948-
\code{(1, 2, 3)}.
955+
\code{(1, 2, 3)}. If no argument is given, returns a new empty
956+
tuple, \code{()}.
949957
\end{funcdesc}
950958

951959
\begin{funcdesc}{type}{object}
@@ -981,7 +989,8 @@ \section{Built-in Functions \label{built-in-funcs}}
981989
\versionadded{2.0}
982990
\end{funcdesc}
983991

984-
\begin{funcdesc}{unicode}{object\optional{, encoding\optional{, errors}}}
992+
\begin{funcdesc}{unicode}{\optional{object\optional{, encoding
993+
\optional{, errors}}}}
985994
Return the Unicode string version of \var{object} using one of the
986995
following modes:
987996

0 commit comments

Comments
 (0)