Python Forum
Why is from code import * different from entering that code directly into the REPL?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why is from code import * different from entering that code directly into the REPL?
#1
...indeed, for code.py being
a = 0
def func():
    global a
    a = 1
after entering that code directly into the REPL and typing
func()
print(a)
I get 1, while I get 0 after a
from code import *
Why? Dear community, I am a noob looking forward to understanding such different behaviors. Any help would be greatly appreciated.
Reply


Messages In This Thread
Why is from code import * different from entering that code directly into the REPL? - by sebi - Apr-03-2019, 07:01 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Eliminate entering QR - Whatsapp web automated by selenium akanowhere 1 3,179 Jan-21-2024, 01:12 PM
Last Post: owalahtole
  My code works on Jupyter Lab/Notebook, but NOT on Visual Code Editor jst 4 1,323 Nov-15-2023, 06:56 PM
Last Post: jst
  problem in entering address of a file in input akbarza 0 732 Oct-18-2023, 08:16 AM
Last Post: akbarza
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 7,706 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  Import XML file directly into Excel spreadsheet demdej 0 919 Jan-24-2023, 02:48 PM
Last Post: demdej
  python multiple try except block in my code -- can we shorten code mg24 10 6,611 Nov-10-2022, 12:48 PM
Last Post: DeaD_EyE
  faster code for my code kucingkembar 19 3,519 Aug-09-2022, 09:48 AM
Last Post: DPaul
  help for use print in REPL jip31 10 4,447 Apr-30-2021, 03:52 PM
Last Post: bowlofred
  Putting code into a function breaks its functionality, though the code is identical! PCesarano 1 2,076 Apr-05-2021, 05:40 PM
Last Post: deanhystad
  HackerRank Problem: Code works on VS Code but not on the HackerRank site Pnerd 3 2,796 Feb-28-2021, 07:12 PM
Last Post: Pnerd

Forum Jump:

User Panel Messages

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