>>>>> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >AP> As I read the language reference the x stands for a target expression. >AP> Now what does it mean to evaluate a target expression like col[key]. >AP> IMO it means finding the location of the item in the collection: the >AP> bucket in the directory, the node in the tree ... grosso mode it >AP> boils down to the call to __setitem__ or __getitem__ depending >AP> on where the col[key] was located in the line (or if you prefer >AP> the view from the interpreter it boils down to the BINARY_SUBSCR >AP> and STORE_SUBSCR opcodes).
>AP> So if the language reference seems to implies that col[key] will >AP> only be evaluated once in a line like: "col[key] += 1" I expect >AP> only one call from __setitem__ or __getitem__ (or only one >AP> from BINARY_SUBSCR or STORE_SUBSCR) You need both the __setitem__ and the __getitem__ otherwise it won't work. I think the "evaluated once" clause is for cases like: f(a)[g(b)] += 1 where f and/or g have side effects. These side effects should then take place only once. Side effects in __setitem__ and __getitem__ is not what it is talking about. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list