Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49509

Re: math functions with non numeric args

References <CAPrcKXLzK1A=y6B6Z5srroT5tnyd1kMO43GS=2mxGpvtxK73xQ@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2013-06-30 13:07 -0600
Subject Re: math functions with non numeric args
Newsgroups comp.lang.python
Message-ID <mailman.4038.1372619286.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Jun 30, 2013 at 12:46 PM, Andrew Z <formisc@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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: math functions with non numeric args Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-30 13:07 -0600

csiph-web