コード例 #1
0
from __future__ import print_function

# http://stackoverflow.com/questions/3536620/how-to-change-a-module-variable-from-another-module
import foo
foo.data = "set from use_modules"
foo.datal.append("use_modules")

import bar
foo.dump()

import baz

print("Baz data id(qualified): ",id(baz.data))
print("Foo data id: ",id(foo.data))
print("Bar.foot data id: ",id(bar.f.data))


class Test(object):
    def __init__(self,data):
        self._data = data


x = [Test(1),Test(2),Test(3)]
import copy

y = copy.deepcopy(x)
#y = x[:]

y[0]._data = -1
print(x[0]._data)
print(y[0]._data)
コード例 #2
0
ファイル: bar.py プロジェクト: Jerdak/jerdak.github.io
from __future__ import print_function
import foo as f

f.dump()
f.data = "set from bar"
f.datal.append("bar")