Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cyclic reference
#1
Hi, today i came across this code:

#test1.py 
x=1
def change(): 
    import test1 
    test1.x=2 
change() 
print(x)
output is:
2
1
I want to ask why this doesn't make a cyclic reference, since change function import a module have the function itself. And also, it's output should be 1,2 instead of 2,1 right ?
Reply


Messages In This Thread
Cyclic reference - by Uchikago - Jul-11-2019, 07:17 AM
RE: Cyclic reference - by stranac - Jul-11-2019, 07:34 AM
RE: Cyclic reference - by Gribouillis - Jul-11-2019, 07:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pass by object reference when does it behave like pass by value or reference? mczarnek 2 2,568 Sep-07-2020, 08:02 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020