Congratulations -- you've found what is probably
the worst typo in the first printing of the 2nd
Edition of this book. As others have pointed
out, it should say arg < res, not arg < args.
For future reference, O'Reilly maintains the full
list of errata for the book, including this one,
here:
http://www.oreilly.com/catalog/lpython2/errata/
Typos happen, of course, and this edition has a
relatively low number of them. But this one is
made all the more maddening by the fact that I've
coded this example correctly at least one hundred
times during classes. Despite this, testing, and
a formal technical review process, typos always
manage to sneak in. Alas, writing computer books
is no place for a perfectionist to be.
--Mark Lutz (
http://www.rmi.net/~lutz)
slyraymond <sl*********@charter.net> wrote in message news:<10*************@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?