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


Groups > comp.lang.python > #68561

Re: 'complex' function with string argument.

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 <ian.g.kelly@gmail.com>
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> <lg779d$5f4$2@speranza.aioe.org> <5327d112$0$2923$c3e8da3$76491128@news.astraweb.com> <lg9rdm$us9$1@speranza.aioe.org> <11b58171-a99b-4ddf-8e6c-7b4f3169c60c@googlegroups.com> <87lhw6po53.fsf@elektro.pacujo.net> <d1f09443-f5d4-4ed6-880f-bc15810a1fdd@googlegroups.com> <87bnx233gd.fsf@elektro.pacujo.net> <mailman.8276.1395225264.18130.python-list@python.org> <877g7q31f7.fsf@elektro.pacujo.net>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 19 Mar 2014 13:35:05 -0600
Subject Re: 'complex' function with string argument.
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.8285.1395257751.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Wed, Mar 19, 2014 at 4:53 AM, Marko Rauhamaa <marko@pacujo.net> wrote:
> Ian Kelly <ian.g.kelly@gmail.com>:
>
>> On Wed, Mar 19, 2014 at 4:09 AM, Marko Rauhamaa <marko@pacujo.net> 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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

'complex' function with string argument. Jayanth Koushik <jnkoushik@gmail.com> - 2014-03-15 09:26 -0700
  Re: 'complex' function with string argument. Mark H Harris <harrismh777@gmail.com> - 2014-03-17 11:18 -0500
    Re: 'complex' function with string argument. Chris Angelico <rosuav@gmail.com> - 2014-03-18 04:03 +1100
      Re: 'complex' function with string argument. Marko Rauhamaa <marko@pacujo.net> - 2014-03-17 20:15 +0200
        Re: 'complex' function with string argument. Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-17 12:28 -0600
        Re: 'complex' function with string argument. Chris Angelico <rosuav@gmail.com> - 2014-03-18 05:59 +1100
          Re: 'complex' function with string argument. Marko Rauhamaa <marko@pacujo.net> - 2014-03-17 21:22 +0200
            Re: 'complex' function with string argument. Chris Angelico <rosuav@gmail.com> - 2014-03-18 06:32 +1100
            Re: 'complex' function with string argument. Steven D'Aprano <steve@pearwood.info> - 2014-03-18 04:08 +0000
      Re: 'complex' function with string argument. Mark H Harris <harrismh777@gmail.com> - 2014-03-17 13:20 -0500
    Re: 'complex' function with string argument. Steven D'Aprano <steve@pearwood.info> - 2014-03-18 04:52 +0000
      Re: 'complex' function with string argument. Chris Angelico <rosuav@gmail.com> - 2014-03-18 15:59 +1100
      Re: 'complex' function with string argument. Mark H Harris <harrismh777@gmail.com> - 2014-03-18 11:14 -0500
        Re: 'complex' function with string argument. wxjmfauth@gmail.com - 2014-03-19 00:30 -0700
          Re: 'complex' function with string argument. Marko Rauhamaa <marko@pacujo.net> - 2014-03-19 10:51 +0200
            Re: 'complex' function with string argument. wxjmfauth@gmail.com - 2014-03-19 02:52 -0700
              Re: 'complex' function with string argument. Marko Rauhamaa <marko@pacujo.net> - 2014-03-19 12:09 +0200
                Re: 'complex' function with string argument. Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-19 04:33 -0600
                Re: 'complex' function with string argument. Marko Rauhamaa <marko@pacujo.net> - 2014-03-19 12:53 +0200
                Re: 'complex' function with string argument. Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-19 13:35 -0600
                Re: 'complex' function with string argument. Skip Montanaro <skip@pobox.com> - 2014-03-19 06:04 -0500
                Re: 'complex' function with string argument. wxjmfauth@gmail.com - 2014-03-19 07:35 -0700
                Re: 'complex' function with string argument. Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-19 12:45 -0600
  Re: 'complex' function with string argument. Mark Dickinson <mdickinson@enthought.com> - 2014-03-17 17:55 +0000
  Re: 'complex' function with string argument. Terry Reedy <tjreedy@udel.edu> - 2014-03-17 18:06 -0400
  Re: 'complex' function with string argument. Skip Montanaro <skip@pobox.com> - 2014-03-17 18:59 -0500
  Re: 'complex' function with string argument. Chris Angelico <rosuav@gmail.com> - 2014-03-18 11:16 +1100
  Re: 'complex' function with string argument. Skip Montanaro <skip@pobox.com> - 2014-03-17 20:07 -0500
  Re: 'complex' function with string argument. Christian Gollwitzer <auriocus@gmx.de> - 2014-03-18 08:04 +0100
    Re: 'complex' function with string argument. Chris Angelico <rosuav@gmail.com> - 2014-03-18 18:11 +1100
    Re: 'complex' function with string argument. Steven D'Aprano <steve@pearwood.info> - 2014-03-18 08:00 +0000
      Re: 'complex' function with string argument. Christian Gollwitzer <auriocus@gmx.de> - 2014-03-18 09:21 +0100
        Re: 'complex' function with string argument. Marko Rauhamaa <marko@pacujo.net> - 2014-03-18 16:00 +0200

csiph-web