1# mode: run
2# tag: pyglobal
3
4"""
5>>> getg()
65
7>>> getg()
85
9>>> getg()
105
11>>> setg(42)
12>>> getg()
1342
14>>> getg()
1542
16>>> getg()
1742
18"""
19
20g = 5
21
22
23def setg(a):
24    global g
25    g = a
26
27
28def getg():
29    return g
30
31
32class Test(object):
33    """
34    >>> global_in_class
35    9
36    >>> Test.global_in_class
37    Traceback (most recent call last):
38    AttributeError: type object 'Test' has no attribute 'global_in_class'
39    >>> Test().global_in_class
40    Traceback (most recent call last):
41    AttributeError: 'Test' object has no attribute 'global_in_class'
42    """
43    global global_in_class
44    global_in_class = 9
45