[Python-ideas] generic Ref class

Adam Atlas adam at atlas.st
Sat Jan 12 21:16:02 CET 2008

On 12 Jan 2008, at 15:03, Aaron Brady wrote:
> Then:
> 	for x in refs( listA ):
> 		x.val+= 1
> Better than:
> 	for i, x in enumerate( listA ):
> 		listA[i]= x+ 1

Don't these do different things? The latter modifies the original  
list, while the former, with your Ref class, apparently modifies (in a  
by-reference sense) a new list that is thrown away once the for loop  
is done.

More information about the Python-ideas mailing list