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


Groups > comp.lang.python > #49509

Re: math functions with non numeric args

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.023
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'string': 0.09; '-10': 0.09; 'ascii': 0.09; 'converts': 0.09; 'python': 0.11; 'bye': 0.16; 'considers': 0.16; 'subject:non': 0.16; 'wrote:': 0.18; 'print': 0.22; 'header:In-Reply-To:1': 0.27; 'fixed': 0.29; 'andrew': 0.30; 'characters': 0.30; 'message-id:@mail.gmail.com': 0.30; 'another': 0.32; 'guess': 0.33; 'subject:with': 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'numbers': 0.61; 'simply': 0.61; '30,': 0.65; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=iMDq19gdPTCTVSdsus8s5isw+i28WPZTvwzEOiajyaM=; b=0G9+lmDlEAS1qQT4zuwoXlMWYrQmoUd19jlu8+Oa2QOCdv1y53gUAlCTk6BrTNs5o2 U8j15TUYi8JrM7Bjq3hz0JO841GNP9X74/oEuqBYkojE087/s91uSADsYu1cWvWZJPBk UCNFWOaDWqRJ302dbwbUp8SOhVquwYWkWA72eetGyfXFV90eaBVHlU0gdD0t+Offc0my 1Jq9oruiWQBIGCsVqgA/4M9euaLGXgaxvqdXihBqaGeM/bB8bZGMKWUJJj+k9Kd4Jqzg K8kW2wp6IFu5Ra3Sv+rbbCEV+m+K93XX6Hkyz7bKP9MJIWE6ynU23Q9gTiv6holyKivP jwJg==
X-Received by 10.68.171.36 with SMTP id ar4mr20208372pbc.195.1372619283657; Sun, 30 Jun 2013 12:08:03 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CAPrcKXLzK1A=y6B6Z5srroT5tnyd1kMO43GS=2mxGpvtxK73xQ@mail.gmail.com>
References <CAPrcKXLzK1A=y6B6Z5srroT5tnyd1kMO43GS=2mxGpvtxK73xQ@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Sun, 30 Jun 2013 13:07:22 -0600
Subject Re: math functions with non numeric args
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4038.1372619286.3114.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372619286 news.xs4all.nl 15950 [2001:888:2000:d::a6]:33794
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49509

Show key headers only | 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