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: 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> <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> From: Ian Kelly Date: Wed, 19 Mar 2014 04:33:34 -0600 Subject: Re: 'complex' function with string argument. To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Wed, Mar 19, 2014 at 4:09 AM, Marko Rauhamaa wrote: > wxjmfauth@gmail.com: > >> Le mercredi 19 mars 2014 09:51:20 UTC+1, Marko Rauhamaa a =E9crit : >>> 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.