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


Groups > comp.lang.python > #81430

Re: "**" in python

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 2014-11-24 16:18 +1100
Subject Re: "**" in python
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16226.1416806303.18130.python-list@python.org> (permalink)

Show all headers | 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