Newbie question

Peter Hansen peter at engcorp.com
Tue Nov 2 09:01:16 EST 2004


Uday wrote:
> 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. 

This is rarely a useful thing to do.  How do you plan to
access the variable in the rest of the code if the name
is generated dynamically?

Usually, people who think they want to do this should be
using a dictionary instead.

-Peter



More information about the Python-list mailing list