"**" in python
Chris Angelico
rosuav at gmail.com
Mon Nov 24 00:18:20 EST 2014
On Mon, Nov 24, 2014 at 3:47 PM, Steven D'Aprano <steve at 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
More information about the Python-list
mailing list