A number of questions asked here could easily be answered by a quick search of the Python Manuals. A prime example is about the behavior of default parameter values.

A recent questioner ended the thread with "The problem with this particular question is that I found it hard to find a query that would give meaningful answers."

The following is intended to show how he might have found an answer to this question and, by extension, how others might answer other questions using the 2.4 to 3.0 manuals. (I do not have 2.6 but presume its manual set works the same as the 3.0 set.)

--------------------------------------
For WinXP (I have no idea of how the manuals works elsewhere):

Open the Python Manuals shortcut.

On the left, click [+] for Language Reference
   (3.0: The Python language reference).

Scan the chapter list to find [+] Compound Statements
[statements with a header line and indented suite].

Click [+], find Function definitions and click on that.
(In 3.0, one can instead directly click Compound Statements since entire chapters rather than just sections are loaded into the right pane.)

Click on the right frame/pane to shift 'focus'.

Enter control-F and wait (at least a second, be patient) to open a Find box.

Enter 'default' (but not too much, such as 'default argument') and click Next. This brings you to the discussion of default parameter values.

Either read or continue clicking Next until you come to the boldfaced line that begins the next paragraph: "Default parameter values are evaluated when the function definition is executed." This is followed by an explanation of why one would usually want 'param = None' + body code rather than 'param = []'.

-----------------------------------------

It helps if one reads all of the language reference and the first chapters of the library reference on built-ins at least once. They are constantly being improved as mistakes and ambiguities are found and reported.

The global module index (top of the left pane) is useful when you know (or maybe just suspect) the name of a module.

Terry Jan Reedy




--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to