How to declare super global variable inside a module library function

like
from library import function

function implement
def function():
declare a global variable

Welcome @imrankhan_pythonLang.

“HowTo Python” questions are more suited on other sites, but I’ll try to help.

You can make a global in the module namespace (1) and access it within functions using the global keyword (2).

TOTAL = 0                                                  # 1


def tally_counter(value):
    """Return an accumulated count.""" 
    global TOTAL                                           # 2
    TOTAL += value
    return TOTAL


[tally_counter(i) for i in range(5)]

# [0, 1, 3, 6, 10]

However, using globals and global are not particularly pythonic. Usually, there is another way, e.g. modules, classes, decorators, etc. Consider elaborating on your query and submitting it on StackOverflow to get more optimal solutions.

Again welcome to Python!