Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'definitions': 0.07; "subject:' ": 0.07; 'indicates': 0.09; 'integers': 0.09; 'subject:string': 0.09; 'violates': 0.09; 'python': 0.11; 'bug': 0.12; '54,': 0.16; 'backward': 0.16; 'constructor.': 0.16; 'disallow': 0.16; 'medieval': 0.16; 'merely': 0.16; 'repr': 0.16; 'unlikely': 0.16; 'valueerror': 0.16; 'zero,': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'discussion': 0.18; 'wed,': 0.18; 'all,': 0.19; 'normally': 0.19; 'later': 0.20; 'meant': 0.20; '>>>': 0.22; 'code,': 0.22; 'example': 0.22; 'rules': 0.22; 'saying': 0.22; 'documented': 0.24; 'interpret': 0.24; 'passes': 0.24; 'simpler': 0.24; 'decide': 0.24; 'compare': 0.26; 'header:In-Reply-To:1': 0.27; 'leave': 0.29; 'am,': 0.29; 'possibility': 0.29; 'raise': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'about.': 0.31; 'another.': 0.31; 'produces': 0.31; "user's": 0.31; 'there.': 0.32; 'option': 0.32; 'says': 0.33; 'cases': 0.33; 'sense': 0.34; 'subject:with': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'curious': 0.36; 'useful': 0.36; "i'll": 0.36; 'should': 0.36; 'to:addr:python- list': 0.38; 'issue': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'called': 0.40; 'remove': 0.60; 'above,': 0.60; 'ian': 0.60; 'worry': 0.60; 'further': 0.61; 'address': 0.63; 'more': 0.64; 'mar': 0.68; 'natural': 0.68; 'behavior': 0.77; 'discover': 0.82; '"hey,': 0.84; 'fortunately': 0.84; 'apparent': 0.91 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=q3iYxVEYoDYTf8VkATlqyda7dOFYtFmfaEItRI6yJlo=; b=j0hCP6vlJ+ZhoPkuhGjHoe3HniHvpMVbY9TbbdNZcbq5/+uj2HabOVyz+cfe2MUoz7 8Pyvq1G0WbD9rYfhOd40mb2UYKn4/hpy/3rmfd+WooRFS2YiM5+ZOgyVmREP+4e3CCBL PBVapylkhFQuP1tbGi21YB9edgZzIYo9C2HmzUMjDf107FNAnUTdr1dLg/imBttyESwz PQwEwDeB4klEPJWH8Q2lgcb9T48FOWVJF9EzuBpiWmic2cIq/KxO7+5aK9xcyMeo6Gw3 f3DpQDpbxaeKPb2AN9vfHdxFfp6mgjNAL9+pe/tNtBuSQMLxa0RgPBw9wLgjHtsGneYr +ADw== X-Received: by 10.68.135.195 with SMTP id pu3mr42369815pbb.70.1395257747648; Wed, 19 Mar 2014 12:35:47 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <877g7q31f7.fsf@elektro.pacujo.net> References: <8c862bec-815e-424c-81e2-8f37ebab1c35@googlegroups.com> <5327d112$0$2923$c3e8da3$76491128@news.astraweb.com> <11b58171-a99b-4ddf-8e6c-7b4f3169c60c@googlegroups.com> <87lhw6po53.fsf@elektro.pacujo.net> <87bnx233gd.fsf@elektro.pacujo.net> <877g7q31f7.fsf@elektro.pacujo.net> From: Ian Kelly Date: Wed, 19 Mar 2014 13:35:05 -0600 Subject: Re: 'complex' function with string argument. To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 48 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395257751 news.xs4all.nl 2830 [2001:888:2000:d::a6]:44622 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68561 On Wed, Mar 19, 2014 at 4:53 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> On Wed, Mar 19, 2014 at 4:09 AM, Marko Rauhamaa wrote: >>> So complex(a, b) is documented to produce a+bj when a and b are integers >>> or floats. What's more natural than saying it produces a+bj when a and b >>> are complex numbers? It's a straightforward generalization that in no >>> way violates the more limited documentation. >> >> When is it ever useful though? [...] It would be better to raise an >> exception in either of the cases above, in my opinion. > > I don't think it matters one way or another. > > Medieval mathematicians had to address an analogous issue when they had > to decide if > > x + 0 > > was meaningful. After all, adding nothing doesn't make any sense and > should raise a ValueError exception... I wasn't aware that algebra had ValueErrors. Describing an operation as "undefined" isn't the same thing. Anyway, if mathematicians discover that the definitions of the past were flawed or incomplete, then they redefine them. Case in point, if we were still using Brahmagupta's rules for zero, then 0/0 would be 0. Python though has backward compatibility to worry about. Because of this, it is much simpler to add wanted behavior than to remove unwanted behavior. If an operation can be generalized but the generalization has no apparent use case, it *may* be better to disallow it, with the possibility of adding it later when a user pops up and says "Hey, this would actually be useful to me", than to allow it from the beginning, and then have no option to remove it later when it turns out to be merely a nuisance. Compare for example the 2-argument int constructor. Normally this is meant to be called like int("42", 13), where it will interpret the digits passed as base 13 and return 54. We might generalize that and say that if the user passes int(42, 13), it should also return 54, seeing that the repr of 42 provides the digits "42". It is more likely though that this call merely indicates a bug in the user's code, and fortunately in this case what Python actually does is to raise a TypeError. Anyway, curious though this tangent is, further discussion is unlikely to produce any useful outcome, so I'll just leave it there.