math functions with non numeric args

Ian Kelly ian.g.kelly at gmail.com
Sun Jun 30 15:07:22 EDT 2013


On Sun, Jun 30, 2013 at 12:46 PM, Andrew Z <formisc at gmail.com> wrote:
> Hello,
>
> print max(-10, 10)
> 10
> print max('-10', 10)
> -10
>
> My guess max converts string to number bye decoding each of the characters
> to it's ASCII equivalent?

No, it leaves the types as they are but simply considers strings to be
"greater than" numbers.  As another poster stated, this is fixed in
Python 3, where strings and numbers are considered inorderable.



More information about the Python-list mailing list