Question

I need to have actual state of my List, which may change anytime.

mylist.py

list = {"key": "value"}

For first time import it's state is actual, but list in mylist.py may be changed. I need to reimport it each time function is called.

somecode.py

def someFunc():
    from mylist import list
    print list
Was it helpful?

Solution

There is a function called reload(module)

import mylist 

def someFunc():
    mylist = reload(mylist) # this may raise syntaxerrors in wrong moments
    list = mylist.list
    print list

Does it work for you?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top