
For iteration and pass-by-reference semantics: class Ref: def __init__( self, val): self.val= val To modify list during iteration: def refs( iterable ): return [ Ref( x ) for x in iterable ] Then: for x in refs( listA ): x.val+= 1 Better than: for i, x in enumerate( listA ): listA[i]= x+ 1 Example is naturally trivial; imagine. No bloat here; get over it.

On Sat, Jan 12, 2008, Aaron Brady wrote:
Good addition to the cookbook if it's not already there. IMO, not appropriate for the standard library. -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ Weinberg's Second Law: If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization.

On Sat, Jan 12, 2008, Aaron Brady wrote:
Good addition to the cookbook if it's not already there. IMO, not appropriate for the standard library. -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ Weinberg's Second Law: If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization.
participants (3)
-
Aahz
-
Aaron Brady
-
Adam Atlas