Global variable assignment issue
<p>I have a problem with assigning global variable names inside a function. Here's what the function looks like:</p>

<pre><code>def nodegen(slabel, dlabel, sx, xy, dx, dy, num):
   for i in range(1, num + 1):
      label = slabel + (i - 1)*dlabel 
      global vars()["n" + str(label)]
      vars()["n" + str(label)] = Node(label, (sx + i*dx, sy + i*dy))
      vars()["n" + str(label)].info()   
</code></pre>

<p>Actually, it's not important what the function does. What is important is that it generates a number num of objects. Every one of them is assigned a variable n1, n2, ..., nnum (the indices do not necessarily have this sequence, it depends on the dlabel variable, but that's not really important). I want to make these variables global, so I can use them outside the function. The problem is line 4 of the code, since it seems the global statement doesn't work with the vars()[] statement. Any ideas on how to solve this problem? I get an "invalid syntax" error message.</p>

<p>Thanks in advance.  </p>
