Hi everybody, Be a the following list, containing list elements which second field is a string.
>>> a = [ [4, "toto"], [5, "cou"] ] >>> a[0][1]="tou" >>> a [[4, 'tou'], [5, 'cou']] OK. Now, I want: * to do the same modification on the list "a" within a function * not to hardcode in this function the position of the string in each element of a. At first sight, we think at defining a function like this: def assign( text_accessor, list_elem, new_textvalue ): text_accessor( list_elem ) = new_textvalue and then doing: assign( lambda elem: elem[1], a[0], "co" ) But it does not work, we obtain: text_accessor( list_elem ) = new_textvalue SyntaxError: can't assign to function call In fact, we should work on the address of text_accessor( list_elem ). How to do that? Thanks Julien -- python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\ 9&1+,\'Z4(55l4('])" "When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong." (first law of AC Clarke) -- http://mail.python.org/mailman/listinfo/python-list