python中的python全局用法和数据结构

有人可以解释一下此代码如何工作吗? dbLevel的用途是什么?如何处理函数和打印?我是这种语言的新手,最重要的是,我不明白这种印刷方式

dlevel = 0  # manage nesting level


def main():
    r = range(11)
    l = [1, 'two', 3, {'4': 'four'}, 5]
    t = ('one', 'two', None, 'four', 'five')
    s = set("It's a bird! It's a plane! It's Superman!")
    d = dict(one=r, two=l, three=s)
    mixed = [l, r, s, d, t]
    disp(mixed)


def disp(o):
    global dlevel

    dlevel += 1
    if isinstance(o, list): print_list(o)
    elif isinstance(o, range): print_list(o)
    elif isinstance(o, tuple): print_tuple(o)
    elif isinstance(o, set): print_set(o)
    elif isinstance(o, dict): print_dict(o)
    elif o is None: print('Nada', end=' ', flush=True)
    else: print(repr(o), end=' ', flush=True)
    dlevel -= 1

    if dlevel <= 1: print()  # newline after outer
def print_list(o):
    print('[', end=' ')
    for x in o:
        disp(x)
    print(']', end=' ', flush=True)


def print_tuple(o):
    print('(', end=' ')
    for x in o:
        disp(x)
    print(')', end=' ', flush=True)


def print_set(o):
    print('{', end=' ')
    for x in sorted(o):
        disp(x)
    print('}', end=' ', flush=True)


def print_dict(o):
    print('{', end=' ')
    for k, v in o.items():
        print(k, end=': ')
        disp(v)
    print('}', end=' ', flush=True)


if __name__ == '__main__': main()

有人可以详细解释一下此代码如何工作吗?