Python: Create a global variable from a string?
<p>Is there a way to create a global variable from a string? I know that you can make a variable from a string like so:</p>

<pre><code>    string = 'hello'
    val = 10
    vars()[string] = val
</code></pre>

<p>Thus making hello a variable equal to 10. I do not know how to make that user input variable global however, this does not work:</p>

<pre><code>    string = 'hello'
    val = 10
    vars()[string] = val
    eval("global " + string)
</code></pre>
