Overwrite global var in one line in Python?
<p>I know that I can write:</p>

<pre><code>foo = 'bar'
def update_foo():
  global foo
  foo = 'baz'
</code></pre>

<p>But do I <em>really</em> need two lines of code there? Python, alas, won't allow me to say</p>

<pre><code>global foo = 'baz'
</code></pre>

<p>I could also mash the two lines together with the unfortunately repetitive</p>

<pre><code>global foo; foo = 'baz'
</code></pre>

<p>Any other shortcuts? I'm on Python 2.6.5, but I'd be curious to hear responses for Python 3 as well.</p>
