semantics of ** (unexpected/inconsistent?)

inhahe inhahe at gmail.com
Mon Nov 30 00:15:25 EST 2009


On Sun, Nov 29, 2009 at 8:04 PM, Esmail <ebonak at hotmail.com> wrote:
> Chris Rebert wrote:
> Wow .. never heard of Concatenative_languages languages before or the
> distinction you make. Your distinction explains the behavior, but I
> find it somewhat counter-intuitive. (I use the Python interpreter frequently
> for small calculations - otherwise I'd never have realized this)


Well I think of it like this
-3**2, because of the order of operations as you know, groups as -(3**2)
now if you set x to -3, (-3) is now automatically, inseparably
grouped. so in a sense by setting x to that you're grouping it.
x == (-3)
x**2 == (-3)**2

if it still seems counterintuitive, what about the fact that it's
exactly the same way in Algebra?

basic algebra:
  -3(superscript)2 is -9
  but if x is -3, then x(superscript)2 is 9



More information about the Python-list mailing list