On Jul 11, 3:53 pm, "Evan Klitzke" <[EMAIL PROTECTED]> wrote: > On 7/11/07, Paul McGuire <[EMAIL PROTECTED]> wrote: > > > On Jul 11, 12:04 pm, David Jones <[EMAIL PROTECTED]> wrote: > > > > In fact, if I put (2**2)**2**2**2 > > > > it comes up with the correct answer, 4294967296 > > > > Actually, the "correct" answer (even by your own demonstration) is > > > 65536. > > > It might be easier to demonstrate if we chose a less homogeneous > > problem: 2**3**2. A right (rightly?) associative language (such as > > Python) reads this as 2**(3**2), or 2**9=512. A left-associative > > language (such as VB) reads this as (2**3)**2 or 8**2=64. As was > > pointed out earlier, left-associativity with exponentiation is of > > little value, since (2**3)**2 is the same as 2**(3*2) or 2**6=64. > > It doesn't have anything to do with the language being left/right > associative, it has to do with the operators in question. For example, > subtraction is always left associative -- you would be really > surprised if 3 - 2 - 1 evaluated to 2. Python happens to choose right > associativity for exponentiation because it is more useful for that > operator, but that doesn't make the language itself right associative. > > -- > Evan Klitzke <[EMAIL PROTECTED]>
Sorry, I meant that Python was right-associative only with respect to exponentiation. All other arithmetic operators are left-to-right (and rightly so). By contrast, VisualBasic evaluates exponentiation left- to-right, so for the sake of this thread, VB is a left-associative exponentiation language. -- Paul -- http://mail.python.org/mailman/listinfo/python-list