[Tutor] min max confusion

János Juhász janos.juhasz at VELUX.com
Thu Feb 8 08:06:22 CET 2007


Hi Frank,


> From: "frank h." <frank.hoffsummer at gmail.com>
> Subject: [Tutor] min max confusion

> >>> t = (952L, 945L, 941L, 939L, 949L, 972L, 956L, 965L, 973L, 965L)
> >>> min(t)
> 939L
> >>> max(t)
> exceptions.TypeError                                 Traceback (most 
recent
> call last)
> TypeError: 'int' object is not callable

> 
> why doesn't max(t) work?! I am using python 2.4.4
> thanks for any insight you might have
> -frank


>>> t = (952L, 945L, 941L, 939L, 949L, 972L, 956L, 965L, 973L, 965L)
>>> min(t)
939L
>>> max(t)
973L

So it should works fine.

>>> help(max)
Help on built-in function max in module __builtin__:

max(...)
    max(sequence) -> value
    max(a, b, c, ...) -> value
 
    With a single sequence argument, return its largest item.
    With two or more arguments, return the largest argument.

The max() function should be overwritten like this:

>>> def max(a, b):
...     print b
... 

And it can be checked easy.

>>> help(max)
Help on function max in module __main__:

max(a, b)

>>> 

In this case, you can use the original builtin max() so:

>>> __builtin__.max()


Best regards,
Janos Juhasz


More information about the Tutor mailing list