[Tutor] operator order

Nick W pacificmorrowind at gmail.com
Thu Jan 31 20:16:37 CET 2013


because python process the expression on the right side of the assignment
first.
ie d *= 3+4 basically is the equivalent of writing (2) * (3+4).
Hope that explains it.
Nick


On Thu, Jan 31, 2013 at 10:36 AM, heathen <godsofliberty at lavabit.com> wrote:

> why is this:
>
> >>> d = 2
> >>> d *= 3 + 4
> >>> d
> 14
>
> not this:
>
> >>> d = 2
> >>> d = d * 3 + 4
> >>> d
> 10
>
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130131/12e7f870/attachment.html>


More information about the Tutor mailing list