On 04/08/12 20:44, Alonzo Quijote wrote:
There must be a good reason that the responders use a tmp variable like this?
But I notice that the same effects can be obtained with:
def setValueAtPosition2(list, pos, value):
for i in pos[:-1]:
list = list[i]
list[pos[-1]] = valu
Thanks for all the help with this. I have 2 very quick follow-up questions:
---
1. Several responses proposed code like this:
def setValueAtPosition(list, pos, value):
tmp = list
for i in pos[:-1]:
tmp = tmp[i]
tmp[pos[-1]] = value
There must be a good reason that the responders u
On Sat, Aug 4, 2012 at 12:28 PM, Alonzo Quijote
wrote:
> Is there a way to define a function which takes
>a list (of lists),
>a position specified by a list of integers [i0,i1,...,in], and
>a value
> and returns the result of setting
> list[i0][i1]...[in]=value
>
> The following fu
Alonzo Quijote wrote:
> Is there a way to define a function which takes
>a list (of lists),
>a position specified by a list of integers [i0,i1,...,in], and
>a value
> and returns the result of setting
> list[i0][i1]...[in]=value
>
> The following function works for positions up to
On 04/08/12 16:58, Alonzo Quijote wrote:
Is there a way to define a function which takes
a list (of lists),
a position specified by a list of integers [i0,i1,...,in], and
a value
and returns the result of setting
list[i0][i1]...[in]=value
Yes it is possible, but if you need th
On Sat, Aug 4, 2012 at 12:28 PM, Alonzo Quijote
wrote:
> Is there a way to define a function which takes
>a list (of lists),
>a position specified by a list of integers [i0,i1,...,in], and
>a value
> and returns the result of setting
> list[i0][i1]...[in]=value
>
> The following fu
Is there a way to define a function which takes
a list (of lists),
a position specified by a list of integers [i0,i1,...,in], and
a value
and returns the result of setting
list[i0][i1]...[in]=value
The following function works for positions up to length 3 only.
Is it possible to writ