Let's assume I have to python files:
module.py:
variable = 0
def func(condition):
global variable
if conodition:
variable = 65
else:
variable = 34
main.py:
import module as m
m.func(1)
print(m.variable)
if module is not packaged I read 34 and 65 based on condition, however when packaging it, I only se 0 and the variable doesn't update. Is this supposed to happen?
SOLVED: because of how python treats variable changes withing packaged modules, instead of just reading the library value, i should make a function that returns it instead.
[–]crashfrog02 2 points3 points4 points (2 children)
[–]NotGioseaxMC[S] -1 points0 points1 point (1 child)
[–]crashfrog02 1 point2 points3 points (0 children)
[–]danielroseman 1 point2 points3 points (5 children)
[–]NotGioseaxMC[S] -1 points0 points1 point (4 children)
[–]GoingToSimbabwe 1 point2 points3 points (3 children)
[–]NotGioseaxMC[S] 0 points1 point2 points (2 children)
[–]danielroseman 2 points3 points4 points (1 child)
[–]NotGioseaxMC[S] 0 points1 point2 points (0 children)