Trouble Understanding O'Reilly Example
Mark Lutz
lutz at rmi.net
Mon Apr 26 11:49:46 EDT 2004
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 <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