Newbie question

Uday ukunapul at
Tue Nov 2 08:30:17 CET 2004

  I would like to know how can I create and assign variables by 
de-referencing the values in other variable in Python. 

I can illustrate what I mean by an example of perl

$a = "task_id";
$i = "1";
$c = $a."_".$i;
$$c = 2;
print "$task_id_1\n";
# Gives the answer as 2

My problem is that I need to dynamically generate a unique 
variable within a for loop in Python. The name of the variable
should be appended by the index of the loop. 

In the above example if $i were an array index, then as we
traverse through the array, a unique variable is defined.

Is there any way to do it in Python??

I am not in python.users mailing list, please reply to me directly.


More information about the Python-list mailing list