In article 87eingrbh9@benfinney.id.au,
Ben Finney ben+pyt...@benfinney.id.au wrote:
Lie Ryan lie.1...@gmail.com writes:
I generally do not expect operator precedence to be reliable at all
Have another read of the thread. The OP's confusion was not over
operator precedence, but over how
Esmail 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.
You shouldn't find it any more surprising than the fact that
a = 2 + 3
print a * 5
gives a
one point of confusion could be the use of ** instead of superscript.
it might make things a little bit more counterintuitive-looking than
with superscripts, since the issue with
would only apply to exponents, as
-5*4
and
a = -5
a*4
return the same answer, and superscripts make it a little
Lie Ryan wrote:
On 11/30/2009 12:38 PM, Esmail wrote:
Thanks all!! I get it now :-)
It helped to have a number of different explanations, thanks
for taking the time to post. Much appreciated.
I generally do not expect operator precedence to be reliable at all
except for:
+ - (binary ops,
On Mon, Nov 30, 2009 at 3:46 AM, Gregory Ewing
greg.ew...@canterbury.ac.nz wrote:
Esmail 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.
You shouldn't find
On Mon, Nov 30, 2009 at 1:53 PM, Chris Rebert c...@rebertia.com wrote:
On Mon, Nov 30, 2009 at 3:46 AM, Gregory Ewing
greg.ew...@canterbury.ac.nz wrote:
Esmail wrote:
Wow .. never heard of Concatenative_languages languages before or the
distinction you make. Your distinction explains the
On 12/1/2009 5:58 AM, inhahe wrote:
i wasn't suggesting it as a feature for python, just pointing out why
it might seem counterintuitive.
I'm interested, what do YOU (inhahe) think the result should be? Should
both become -9 or both become 9. What was your expectation when you
wrote that
On Sun, Nov 29, 2009 at 5:58 PM, Esmail ebo...@hotmail.com wrote:
Brian J Mingus wrote:
I think you answered your own question. 3**2 comes first in the order of
operations, followed by the negation.
No, that's not the problem, I'm ok with the operator precedence of - vs **
My problem
MRAB pyt...@mrabarnett.plus.com writes:
Most programming languages don't differentiate in text between the
number negative 3 and the expression negated 3. APL does. The
former is written as ¯3 (3 preceded by the overscore character) and
the latter as -3 (3 preceded by the minus sign).
Well,
On Mon, Nov 30, 2009 at 2:05 PM, Lie Ryan lie.1...@gmail.com wrote:
On 12/1/2009 5:58 AM, inhahe wrote:
i wasn't suggesting it as a feature for python, just pointing out why
it might seem counterintuitive.
I'm interested, what do YOU (inhahe) think the result should be? Should both
become
Ok, this is somewhat unexpected:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
-3**2
-9
x = -3
x**2
9
I would have expected the same result in both cases.
Initially I would have expected -3**2
On Sun, Nov 29, 2009 at 5:39 PM, Esmail ebo...@hotmail.com wrote:
Ok, this is somewhat unexpected:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
-3**2
-9
x = -3
x**2
9
I would have
On Sun, Nov 29, 2009 at 4:39 PM, Esmail ebo...@hotmail.com wrote:
Ok, this is somewhat unexpected:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
-3**2
-9
x = -3
x**2
9
I would have
Brian J Mingus wrote:
I think you answered your own question. 3**2 comes first in the order of
operations, followed by the negation.
No, that's not the problem, I'm ok with the operator precedence of - vs **
My problem is why I don't get the same result if I use the literal -3 or
a
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
On 29-Nov-09 19:50 PM, Chris Rebert wrote:
On Sun, Nov 29, 2009 at 4:39 PM, Esmailebo...@hotmail.com wrote:
Ok, this is somewhat unexpected:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
-3**2
-9
I think you answered your own question. 3**2 comes first in the order
of operations, followed by the negation.
No, that's not the problem, I'm ok with the operator precedence of - vs **
My problem is why I don't get the same result if I use the literal -3 or
a variable that contains -3 (x
It's just like in algebra. You evaluate exponents before the - which, after
all, is just another way to write -1, or times-negative-one. However, a
variable with a negative value is not the same as a value that is being
multiplied by a negative.
-3 ** 2 = (-1)(3)^(2) in algebraic terms.
Esmail ebo...@hotmail.com writes:
Brian J Mingus wrote:
I think you answered your own question. 3**2 comes first in the
order of operations, followed by the negation.
No, that's not the problem, I'm ok with the operator precedence of - vs **
My problem is why I don't get the same
* Esmail:
Ok, this is somewhat unexpected:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
-3**2
-9
x = -3
x**2
9
I would have expected the same result in both cases.
Initially I would have
Esmail wrote:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
-3**2
-9
x = -3
x**2
9
I would have expected the same result in both cases.
Initially I would have expected -3**2
Thanks all!! I get it now :-)
It helped to have a number of different explanations, thanks
for taking the time to post. Much appreciated.
Cheers,
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
On 11/30/2009 12:38 PM, Esmail wrote:
Thanks all!! I get it now :-)
It helped to have a number of different explanations, thanks
for taking the time to post. Much appreciated.
I generally do not expect operator precedence to be reliable at all
except for:
+ - (binary ops, not the unary)
*
Lie Ryan lie.1...@gmail.com writes:
I generally do not expect operator precedence to be reliable at all
Have another read of the thread. The OP's confusion was not over
operator precedence, but over how names resolve to values in
expressions.
--
\ “Life does not cease to be funny when
On Sun, Nov 29, 2009 at 8:04 PM, Esmail ebo...@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
25 matches
Mail list logo