semantics of ** (unexpected/inconsistent?)

Esmail ebonak at hotmail.com
Sun Nov 29 20:04:01 EST 2009


Chris Rebert wrote:
> 
> _No_, because using the variable evaluates "-3" as a unit separately
> by itself, before the exponentiation ever occurs; it's the same as the
> difference between (-3)**2 and -3**2.
> Python is not a concatenative programming language[*]; you can't
> directly textually replace a variable with its value and expect to get
> the same result from an expression. For instance, in this case, you
> need to add the parentheses.
> 
> Cheers,
> Chris
> --
> http://blog.rebertia.com
> 
> [*] http://en.wikipedia.org/wiki/Concatenative_language

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)

Thanks,

Esmail




More information about the Python-list mailing list