Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'explicitly': 0.05; 'subject:Python': 0.06; '21,': 0.07; 'explicit': 0.07; 'float': 0.07; 'subject:Why': 0.09; 'vast': 0.09; 'cc:addr:python-list': 0.11; 'cleanly': 0.16; 'division,': 0.16; 'division.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'magic': 0.16; 'non-trivial': 0.16; 'operands': 0.16; 'truncating': 0.16; 'types,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'case.': 0.24; 'fine': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'division': 0.31; 'operators': 0.31; 'trivial': 0.31; 'cases': 0.33; 'common': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'choosing': 0.36; 'done': 0.36; 'subject:?': 0.36; 'two': 0.37; 'being': 0.38; 'enough': 0.39; 'either': 0.39; 'easy': 0.60; 'most': 0.60; "you're": 0.61; 'between': 0.67; 'different.': 0.84; "it'd": 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=8D9r41O0aWjQnR0Su6xXjz9e+iwrrBPO9CRrM+wZ6a8=; b=U5IVkLN40XM1t25c4ekcovO9/wTpbtFFwTsMLddITtZomNXC9r00THqeFSEl2HHLbs 0SjTTmwYyGE5w4hipkmSJt1nqf7lvVWcv7Mlq0rBpyPxAyudz78PHe0Ptt0PVWdHeJAD 6X2itJCGI48LzT0mrXI2pJUVmKfCKZAh/bZbtcv+XhAoNMRQVfzfmTh9CVEkN/3pjNKI It3v/TuBeupBuRGVkvNNqAjxprfM8nP6ORijbQasPGHOvzotuVvSBNdAeVYblZG6BxNb HXpKrfjl8rgJyqXiM0GyoTK9jzl2iQfwSsJWArO5FFAe7e9jlcdyLzyDPItg20bRqhwn iqNQ== MIME-Version: 1.0 X-Received: by 10.52.0.193 with SMTP id 1mr7789146vdg.0.1398036249549; Sun, 20 Apr 2014 16:24:09 -0700 (PDT) In-Reply-To: References: <7x8ur1esa5.fsf@ruckus.brouhaha.com> Date: Mon, 21 Apr 2014 09:24:09 +1000 Subject: Re: Why Python 3? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398036251 news.xs4all.nl 2916 [2001:888:2000:d::a6]:36096 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70439 On Mon, Apr 21, 2014 at 8:52 AM, Gregory Ewing wrote: > Chris Angelico wrote: > >> Truncating vs true is not the same as int vs float. If you mean to >> explicitly request float division, you call float() on one or both >> arguments. You're being explicit about something different. > > > If you know you're dealing with either ints or floats, > which is true in the vast majority of cases, then you > know that / will always perform float division. And that's what I mean about the common non-trivial case. It's easy enough to come up with contrived or trivial cases that use any types, but in most cases, it'd be fine to explicitly call float() on one of the operands to explicitly request floating-point division. Choosing between two division operators is not the same thing as choosing a data type. Explicitly choosing float division: x / float(y) Explicitly choosing to truncate: math.trunc(x / y) Both explicit forms can be done cleanly without empowering the language with the magic of int/int->float. ChrisA