Create multiple variables (with a loop?)

Chris Rebert clp2 at
Fri Jun 5 15:43:15 EDT 2009

On Fri, Jun 5, 2009 at 12:35 PM, Philip
Gröger<philip.groeger at> wrote:
> Hi,
> I need to create multiple variables (lets say 10x10x10 positions of atoms).
> Is it possible to create them through a loop with some kind of indexing like
> atom000, atom001, etc?
> Or is this a very bad idea?

Yes, very bad idea. Use a collection of some sort instead (list, dict,
set). Dynamic variable names are usually evil.

> Thing is ... i want to create a grid of atoms in vpython and then calculate
> the forces for each of them (to their neighbours). Don't know how else I
> could do that. Maybe a huuuge matrix?

Yup, that sounds like a promising possibility. You might want to look
at NumPy -


More information about the Python-list mailing list