Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!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.051 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'float': 0.07; "subject:' ": 0.07; 'literal': 0.09; 'subject:string': 0.09; 'cc:addr:python- list': 0.11; "(i'm": 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'literal.': 0.16; 'minus': 0.16; 'str()': 0.16; 'unary': 0.16; 'wrote:': 0.18; 'not,': 0.20; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'sorry,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'closer': 0.31; 'consisting': 0.31; "skip:' 40": 0.31; 'probably': 0.32; 'maybe': 0.34; 'subject:with': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'skip:o 20': 0.38; 'easiest': 0.38; 'skip:- 10': 0.38; 'expect': 0.39; 'even': 0.60; 'expression': 0.60; 'number,': 0.60; 'then,': 0.60; 'tell': 0.60; "you're": 0.61; 'talking': 0.65; 'mar': 0.68; '5:15': 0.84; 'proves': 0.84; 'sum.': 0.84; 'tricky': 0.84; 'to:none': 0.92; 'outcome': 0.93 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=6uvYwNJb9iBj3AHKWiSyNaEfm5NZWSLPA7bMDVSBaWw=; b=XD60XbefkC3EYw3asr3l+L/uS6qzh5v3cZhQRl+fUBi/Ix30NbK8IGPrtrcHSR+OQY QN+dXiNz6FQD65IKC1REta6ivm9/aIkvdj5jNafDkPz2lqR+fMvX33H2rW3Y8vmoGM+0 5PsRKJX5C2PBAl7/2W6JBY10L7uOWVOjC34CiExakqgzvW7MKDplSLC9e34aAeyHMBHX kHMrl+C6ujNLOYAsX4IVAG7Mpu2h3yBcORdWj0+z44jteMM7xOvnkefilDWFcaMpFqir vHHThT1QiPTuRxW6VtdreM36WyJ6Dby1s6nhT5AMMAIoHpGF3/eBQ1A9aMFOgx6YNV2T poPA== MIME-Version: 1.0 X-Received: by 10.66.11.66 with SMTP id o2mr5261281pab.142.1395082790978; Mon, 17 Mar 2014 11:59:50 -0700 (PDT) In-Reply-To: <87y508r8ro.fsf@elektro.pacujo.net> References: <8c862bec-815e-424c-81e2-8f37ebab1c35@googlegroups.com> <87y508r8ro.fsf@elektro.pacujo.net> Date: Tue, 18 Mar 2014 05:59:50 +1100 Subject: Re: 'complex' function with string argument. 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395082795 news.xs4all.nl 2942 [2001:888:2000:d::a6]:38488 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68453 On Tue, Mar 18, 2014 at 5:15 AM, Marko Rauhamaa wrote: >>> This '3 + 2j' is not a number, its an algebraic sum. >>> >>> This '3+2j' is a complex number. Ok, maybe not, but its closer to what >>> we expect (I'm sorry, but I like i instead of j ) >> >>Hmm. That's a pretty tricky distinction. > > Is "-2.0" a literal? > > What's the outcome of > > -2.0.__str__() If you mean (-2.0).__str__(), then it returns '-2.0', but that proves nothing. Lots of objects have a str() which isn't a literal. Closer to what you're talking about would be repr(), but even then, it doesn't prove that something's a literal. The easiest way to tell is probably ast.parse(): >>> ast.dump(ast.parse("-2.0")) 'Module(body=[Expr(value=UnaryOp(op=USub(), operand=Num(n=2.0)))])' It's an expression consisting of unary minus and the float literal 2.0. ChrisA