Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'cpython': 0.05; 'explicit': 0.07; 'string': 0.09; '-10': 0.09; 'ascii': 0.09; 'converts': 0.09; 'types:': 0.09; 'python': 0.11; 'windows': 0.15; 'bye': 0.16; 'str()': 0.16; 'subject:non': 0.16; 'typeerror:': 0.16; 'with?': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; "shouldn't": 0.24; 'header:In-Reply- To:1': 0.27; 'fixed': 0.29; 'andrew': 0.30; 'characters': 0.30; 'strongly': 0.30; '"",': 0.31; 'another.': 0.31; 'file': 0.32; '(most': 0.33; 'guess': 0.33; 'subject:with': 0.35; 'something': 0.35; 'convert': 0.35; 'received:google.com': 0.35; 'message- id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'more': 0.64; 'behavior': 0.77; '9.1': 0.84; 'freebsd': 0.84; 'dealt': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=CJUDV/5fruaaO0BtpWLmPs4i81avyqlDvC5Jor3H474=; b=tqXcBEbm7AWbkgqRbXqAnV6fS+RF3F4aZofZWDFDbk5VXkqJUJqhH329o/ebUo/hRy F9YlZus/lIGFdqkuU11aGglltn+mnlcGKul92zePj4Z2vLsUWhq2bcl3enrmROkTu4nS OIMmy74QCLrM8muZL1Vv6LDI6NGLHQ5eQpGoLIhNcjfDMZe+2SwBQYGT/mlEFF9n5XRT /dO506WbT3lF5v2lHgk2l92aiITrwovS+bGtt/yGEZp8NksqwhMMKbhc0fkx1wHKsUCw 6tJK/vYj4rGuMLF3RsuuRO9tqZLJoLAZvzptDRpWT2xy5Lg8ggy7FauOp8HEHDf89nfs +poQ== X-Received: by 10.50.21.70 with SMTP id t6mr12209671ige.36.1372618478110; Sun, 30 Jun 2013 11:54:38 -0700 (PDT) Date: Sun, 30 Jun 2013 13:53:55 -0500 From: Andrew Berg User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: "comp.lang.python" Subject: Re: math functions with non numeric args References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372618487 news.xs4all.nl 15901 [2001:888:2000:d::a6]:55836 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49507 On 2013.06.30 13:46, Andrew Z 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? > > Where can i read more on exactly how the situations like these are dealt with? This behavior is fixed in Python 3: >>> max('10', 10) Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: int() > str() Python is strongly typed, so it shouldn't magically convert something from one type to another. Explicit is better than implicit. -- CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 9.1