"**" in python

Chris Angelico rosuav at gmail.com
Mon Nov 24 06:18:20 CET 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

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".




More information about the Python-list mailing list