Re: multiple assignments (was: My first Python program)

2010-10-14 Thread Ian Kelly
On Wed, Oct 13, 2010 at 3:53 PM, Ethan Furman wrote: > Ian Kelly wrote: > >> here is an example >> where the order of assignment actually matters: >> >> >>> d['a'] = d = {} >> Traceback (most recent call last): >> File "", line 1, in >> NameError: name 'd' is not defined >> >>> d = d['a'] =

Re: multiple assignments

2010-10-14 Thread Ben Finney
Ethan Furman writes: > Ah! I was thinking the assignments went in a filter fashion, but now > what I think is happening is that the first item is bound to the last, > then the next item is bound to the last, etc, etc. > > Is this correct? Assignment is always the same direction: the rightmost o

Re: Multiple assignments simplification

2005-10-13 Thread bearophileHUGS
Thank you George Sakkis for your fast and accurate answer. In my life I am encountering lot of graph-based solutions to my problems. I'll try to implement your solution as soon as possible. Fredrik Lundh>working on a Python to C/C++ translator without knowing what kind of optimizations a C/C++ co

Re: Multiple assignments simplification

2005-10-13 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I don't know if C++ compilers can do such optimizations. working on a Python to C/C++ translator without knowing what kind of optimizations a C/C++ compiler can do for you sounds like a great way to waste your time... (I would be rather bit surprised if any contemporar

Re: Multiple assignments simplification

2005-10-12 Thread George Sakkis
<[EMAIL PROTECTED]> wrote: > [snipped] > > Do you know some algorithm (or you can give some suggestions) to > minimize the number of simple assignments needed for a "regular" > situation like that? You can formulate the task as a graph-theoretic problem by representing the set of assignments as