On Tue, Apr 7, 2009 at 8:59 PM, Alexandru Moșoi <brtz...@gmail.com> wrote:

> Not necessarily. For example C/C++ doesn't define the order of the
> operations inside an expression (and AFAIK neither Python) and
> therefore folding 2 * 3 is OK whether b is an integer or an arbitrary
> object with mul operator overloaded. Moreover one would expect * to be
> associative and commutative (take a look at Python strings); if a * 2
> * 3 returns a different result from a * 6 I will find it very
> surprising and probably reject such code.

Multiplication is not associative for floats:

>>> a = 0.1
>>> a*3*5
1.5000000000000002
>>> a*(3*5)
1.5

Fredrik
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to