Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'wed,': 0.03; 'python.': 0.04; '3.2': 0.05; 'typing': 0.05; 'subject:Python': 0.06; 'python': 0.08; 'types:': 0.09; 'pm,': 0.10; '>>>': 0.12; 'win32': 0.12; 'wrote:': 0.14; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; 'integer.': 0.16; 'permitted.': 0.16; 'rationale': 0.16; 'sorting': 0.16; 'str()': 0.16; 'traceback': 0.16; '(most': 0.16; 'cc:addr:python-list': 0.17; 'cheers,': 0.19; 'header:In-Reply-To:1': 0.21; 'seems': 0.21; 'cc:2**0': 0.22; 'feb': 0.23; 'cc:no real name:2**0': 0.23; 'integer': 0.23; 'last):': 0.23; 'received:209.85.161.46': 0.23; 'received:mail- fx0-f46.google.com': 0.23; 'received:209.85.161': 0.26; 'string': 0.26; 'fixed': 0.27; 'message-id:@mail.gmail.com': 0.28; 'bit': 0.30; 'cc:addr:python.org': 0.30; 'typeerror:': 0.30; "can't": 0.32; 'generally': 0.33; 'things': 0.33; 'file': 0.34; 'there': 0.35; '"",': 0.35; 'received:google.com': 0.37; 'received:209.85': 0.37; 'subject:: ': 0.38; 'received:209': 0.39; 'add': 0.39; 'allows': 0.40; 'more': 0.60; 'viewed': 0.82; 'concatenate': 0.84; 'enforced': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=NUDLrU6S4Ytym3T+tpaUHCRX9SlcA8+WMAUnle++a3M=; b=b/OuI5KU0az/BolarfQMalGa8X53JgcXrjZoPrEgc46NXd9EAmtj3oOLWiVvtM+4dt ibP8gj3grHlnQsdlwp8OYsn1cc/orphQvQEAM+wyOl/FlblrydfI3CYhe287LLZKFb9a 5t6tiIpvoEPpkSVEpMSxHnF6lnDS/pdA41CzU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=LG+LfyB6AuAqX3wnxtWxc6Jbihi0iRn4qHxB8vYcUNUnLX8jQcnbKeV7uM1ZFmmvO6 CFle47PuGriBUDcB2KYGwEg2iAoCyGfu+W7tOzMPXWtrQVYy3D74wo0lFbqLxx+7E0+1 0DkMEVPQL1+KmQIvbQT86WyWcTx6eD63OOPuk= MIME-Version: 1.0 In-Reply-To: <0dda7cc8-e1c0-409d-b993-b8aec379f7bd@hd10g2000vbb.googlegroups.com> References: <0dda7cc8-e1c0-409d-b993-b8aec379f7bd@hd10g2000vbb.googlegroups.com> From: Ian Kelly Date: Wed, 1 Jun 2011 13:16:24 -0600 Subject: Re: Comparison operators in Python To: Anirudh Sivaraman Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 21 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306955816 news.xs4all.nl 49039 [::ffff:82.94.164.166]:36797 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6819 On Wed, Jun 1, 2011 at 12:50 PM, Anirudh Sivaraman wrote: > Hi > > I am a relative new comer to Python. I see that typing is strongly > enforced in the sense you can't concatenate or add a string and an > integer. However comparison between a string and an integer seems to > be permitted. Is there any rationale behind this ? It allows things like sorting of heterogeneous lists. It's generally viewed as a wart, though, and it was fixed in Python 3: Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 'x' < 5 Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: str() < int() Cheers, Ian