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

Skip to content

Commit 8b09f49

Browse files
committed
Make the examples for "Default Argument Values" more presentable and
less hostile to newbie use at the interactive prompt. This is in response to SF bug #458654.
1 parent 9c75ff7 commit 8b09f49

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

Doc/tut/tut.tex

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,10 @@ \subsection{Default Argument Values \label{defaultArgs}}
13531353

13541354
\begin{verbatim}
13551355
i = 5
1356-
def f(arg = i): print arg
1356+
1357+
def f(arg=i):
1358+
print arg
1359+
13571360
i = 6
13581361
f()
13591362
\end{verbatim}
@@ -1366,9 +1369,10 @@ \subsection{Default Argument Values \label{defaultArgs}}
13661369
the arguments passed to it on subsequent calls:
13671370

13681371
\begin{verbatim}
1369-
def f(a, l = []):
1370-
l.append(a)
1371-
return l
1372+
def f(a, L=[]):
1373+
L.append(a)
1374+
return L
1375+
13721376
print f(1)
13731377
print f(2)
13741378
print f(3)
@@ -1386,11 +1390,11 @@ \subsection{Default Argument Values \label{defaultArgs}}
13861390
you can write the function like this instead:
13871391

13881392
\begin{verbatim}
1389-
def f(a, l = None):
1390-
if l is None:
1391-
l = []
1392-
l.append(a)
1393-
return l
1393+
def f(a, L=None):
1394+
if L is None:
1395+
L = []
1396+
L.append(a)
1397+
return L
13941398
\end{verbatim}
13951399

13961400
\subsection{Keyword Arguments \label{keywordArgs}}

0 commit comments

Comments
 (0)