I'm trying to think of ways to extend a list variable in one python file (original.py) from a completely different one (addition.py).
The catch is that I can't add any lines to the original.py file.
Is this remotely possible? I'd like to do it with the stock Python libs rather than adding any batch files, etc. as a second process.
if the list in original.py
is defined as a module level variable you can access it from outside to append, remove, sort etc.
# original.py
original_list = [1,2,3]
and
# addition.py
import original
original.original_list.append(4)
print original.original_list
# [1, 2, 3, 4]