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


Groups > comp.lang.python > #68546

Re: 'complex' function with string argument.

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.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.035
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'explicit': 0.07; "subject:' ": 0.07; 'integers': 0.09; 'subject:string': 0.09; 'violates': 0.09; 'omitted,': 0.16; '\xe9crit': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'passing': 0.19; '>>>': 0.22; 'saying': 0.22; 'documented': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'raise': 0.29; 'said,': 0.30; 'message- id:@mail.gmail.com': 0.30; '1.4': 0.31; '>>>>': 0.31; 'produces': 0.31; 'probably': 0.32; 'cases': 0.33; 'programmers': 0.33; 'subject:with': 0.35; 'case,': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'edge': 0.36; 'useful': 0.36; 'so,': 0.37; 'two': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'above,': 0.60; 'catch': 0.60; 'numbers': 0.61; 'more': 0.64; 'chance': 0.65; 'mar': 0.68; 'natural': 0.68; 'confusing': 0.84; 'mars': 0.84
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:content-transfer-encoding; bh=HzPziGuBHoX3/9RlU1MWK8Hy+i+u86AwWlaFYN+UqnA=; b=gL7LQAgYg8NMf62ew/W/g3+zNOY+W2fEEVZycLs7TOSEUAlHTWRv5JtR7D5MQ34jEA 7HElTWSh1nJbbPFFlkc9zHhwfuhhgeqYWpp8eiYCX7xHL5GImsGaVBZSQBFlwqrZCDyN sDUDGkb/4qV2iQW1gzyxdTtyan3/Fe98ilVRtAM0aSzsVxa1mpEfvc/WjFn8GtG4Obm7 NwKsmgpwbc49c0ErZ+5RpE1BSlu9geXtJVLyIqyub3yH/+qRa18/OwNIt5s9IaguImTO Cl5I7N+0u2OGv3evI5MfmEdgBBVOOD5jSU7oKbq/PjsEeBNCD3y45Xf8FDsL+Rpv/u8F kfXQ==
X-Received by 10.67.13.134 with SMTP id ey6mr39602686pad.44.1395225254659; Wed, 19 Mar 2014 03:34:14 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <87bnx233gd.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>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Wed, 19 Mar 2014 04:33:34 -0600
Subject Re: 'complex' function with string argument.
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
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.8276.1395225264.18130.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1395225264 news.xs4all.nl 2891 [2001:888:2000:d::a6]:45959
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68546

Show key headers only | View raw


On Wed, Mar 19, 2014 at 4:09 AM, Marko Rauhamaa <marko@pacujo.net> wrote:
> wxjmfauth@gmail.com:
>
>> Le mercredi 19 mars 2014 09:51:20 UTC+1, Marko Rauhamaa a écrit :
>>> wxjmfauth@gmail.com:
>>> >>>> complex(2, 1+1j)
>>> > (1+1j)
>>>
>>> I find it neat, actually.
>>
>>>>> # tricky: yes, neat: no
>>>>> complex(1+1j, 2)
>> (1+3j)
>
> 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?  I only see a use for passing a as
complex if b is omitted, and I don't see any use for passing b as
complex.  If there's no use case, then it's just a confusing edge case
that will catch unsuspecting programmers who thought the data they
were passing in was real-valued when actually it wasn't.  It would be
better to raise an exception in either of the cases above, in my
opinion.  If you really want to form a complex a+bj from two other
complex numbers, there is always the explicit (a + b * 1j).

That said, complex numbers have been around since 1.4 or so, and
there's probably not much chance to change it now.

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