Trouble Understanding O'Reilly Example

Elaine Jackson elainejackson7355 at home.com
Mon Apr 26 00:05:25 EDT 2004


This is one of those "V8 bugs" that make you smack your forehead: line 4 of the
function definition should read " if arg < res: ". Fix that, and everything
works as expected.

"slyraymond" <sly_raymond at charter.net> wrote in message
news:108p21f7asq1cc8 at corp.supernews.com...
| On page 214 of _Learning Python_, the following function is described as one
| that will return the smallest item in a group of arguments:
|
| def min1(*args):
|   res = args[0]
|   for arg in args[1:]:
|     if arg < args:
|       res = arg
|   return res
|
| However, when the function called with...
|
| print min1(3,4,1,2)
|
| ...it returns:
|
| 2
|
| Why?





More information about the Python-list mailing list