When different modules in Python import an object in the same module, are they all the same object?

suppose I define an object obj in the module base , and then import > object obj .

in the modules a , b and c .

then I modified obj in the module a . Will the obj in the modules b and c be modified accordingly? Why?

Mar.09,2021

Let me give you a simple example (environment: Python shell 3.6.5)

step1 : write t.py and save it on your desktop.

clipboard.png

step2: shellpath

clipboard.png

step3: import ttest

clipboard.png

step4:

clipboard.png
clipboard.png
,py

:
pythonpyshell)1impreload0

.


  • base:


  • a:


  • b:


  • run.py:


  • :


from base import num, lst num, lst, num base, lst base.

import base num, lst, base.

:

  • from xxx import xxx
  • import xxx module.xxx

, ,

:





python m_all.py:

clipboard.png

because this is actually the same object

Menu