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


Groups > comp.lang.python > #81430

Re: "**" in python

Path csiph.com!usenet.pasdenom.info!news.franciliens.net!news.muarf.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'syntax': 0.04; 'alignment': 0.07; 'operator,': 0.09; 'works.': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; '24,': 0.16; 'argument:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'no-op': 0.16; 'url:peps': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'appears': 0.22; 'cc:addr:python.org': 0.22; 'url:dev': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'see,': 0.30; 'message- id:@mail.gmail.com': 0.30; 'accountant,': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'url:python': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'raising': 0.36; 'url:org': 0.36; 'positive': 0.37; 'nov': 0.38; 'url:library': 0.38; 'pm,': 0.38; 'how': 0.40; 'even': 0.60; 'negative': 0.60; 'then,': 0.60; 'numbers': 0.61; "you're": 0.61; 'back': 0.62; 'developed': 0.63; 'skip:n 10': 0.64; 'hand': 0.80; 'power,': 0.91; 'to:none': 0.92
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=KQI4eHtJdDlBhWHIQegHhkbNb6ckmtdxD7da3Ti09S0=; b=QEmIanS2YBGbPoRFg+96hehbxqexxT0hZgIXDIb2p3G7d6zdsFjLzfMlODvKU5NUTU CNx7upbNAFwT6XwtLQbm5sW7ho66EQyI0ZEtpbvVsKCAjmDMoRD8Ja+y/FKpOUlndqPx RIK5LJ8KBorasOWoL3tgV20dG+odPATBaP4xWhyFQ6hzZRnaTqRTOUg1kFIO0JpluKMZ JWXgONPAiPFog4BiTC9aezPLaoPo4IgbmCSH564vvgw6EXAxMeeelhJwVpbzb8yfnkrF jtv7kxKHfHXdBPXkTy+rr9CTIPDWMNa3ZFuMKKBKGjDE3OkuO/XHsw7PI49WU5x36MAC neUw==
MIME-Version 1.0
X-Received by 10.42.64.143 with SMTP id g15mr15558760ici.59.1416806300415; Sun, 23 Nov 2014 21:18:20 -0800 (PST)
In-Reply-To <5472b869$0$2855$c3e8da3$76491128@news.astraweb.com>
References <20141123184316.77485a91@bigbox.christie.dr> <20141124010003.GA44963@cskk.homeip.net> <CAGGBd_pVNSCqhO-WAPW5bq8B80s+Cn2A7+A_Qgh8CzOY=o4hjA@mail.gmail.com> <mailman.16217.1416793733.18130.python-list@python.org> <5472b869$0$2855$c3e8da3$76491128@news.astraweb.com>
Date Mon, 24 Nov 2014 16:18:20 +1100
Subject Re: "**" in python
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <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.16226.1416806303.18130.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416806303 news.xs4all.nl 2848 [2001:888:2000:d::a6]:43200
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81430

Show key headers only | View raw


On Mon, Nov 24, 2014 at 3:47 PM, Steven D'Aprano <steve@pearwood.info> wrote:
> Hmmm, it appears that ** is a no-op that always returns its left hand
> argument:
>
> py> -1**12
> -1

Ahh but you see, you misunderstand how the whole negative-numbers
thing works. You have your syntax wrong. Python was developed by an
accountant, and you write negative numbers like this:

>>> (1)**12
1

And then, because you're raising it to an even power, you get back
positive one. The hyphen is actually an alignment operator, and it
means "left-align this value".

https://www.python.org/dev/peps/pep-0461/
https://docs.python.org/2/library/stdtypes.html#string-formatting

:)

ChrisA

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


Thread

Re: "**" in python Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-23 19:48 -0600
  Re: "**" in python llanitedave <llanitedave@birdandflower.com> - 2014-11-23 18:30 -0800
  Re: "**" in python Steven D'Aprano <steve@pearwood.info> - 2014-11-24 04:47 +0000
    Re: "**" in python Chris Angelico <rosuav@gmail.com> - 2014-11-24 16:18 +1100
  Re: "**" in python albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-12-15 10:33 +0000
    Re: "**" in python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-15 22:31 +1100

csiph-web