Change referenced variable value,referencedvariable,#//File: sma


#//File: small.pyx = 1y = [1, 2]#//////////////////////////////////////////////////////////////////////////#//Main1.pyfrom small import x, y      # copy two names outx = 42                      # changes local x only    y[0] = 42                   # changes shared mutable in-place#//////////////////////////////////////////////////////////////////////////#//Main2.pyimport small                      # get module name (from doesn't)print small.x                     # small's x is not my xprint small.y                     # but we share a changed mutable#//////////////////////////////////////////////////////////////////////////#//Main3.pyfrom small import x, y            # copy two names outprint x = 42                      # changes my x only#//////////////////////////////////////////////////////////////////////////#//Main4.pyimport small                      # get module nameprint small.x = 42                # changes x in other module

评论关闭