>>> x = 'global'
>>> def f():
...   print x
...
>>> f()
global
>>> def f2():
...   print x
...   x = 'local'
...
>>> f2()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 2, in f2
UnboundLocalError: local variable 'x' referenced before assignment

ってなるのは何故?