Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There may be a bug occured when I use 'global' keyword. #10

Open
coderelease opened this issue Apr 18, 2022 · 1 comment
Open

There may be a bug occured when I use 'global' keyword. #10

coderelease opened this issue Apr 18, 2022 · 1 comment

Comments

@coderelease
Copy link

coderelease commented Apr 18, 2022

If loaded the ipython-autoimport module, It will be found that the x variable can not be changed by function which global keyword is inside.

x = "AAAAA"
def myfunc():
  global x
  x = "BBBBB"

myfunc()

print(x)

the correct output is "BBBBB", but "AAAAA" output when use ipython autoimport.

@anntzer
Copy link
Owner

anntzer commented Apr 18, 2022

Good catch. This probably requires mucking with ip.global_user_ns (instead of just ip.user_ns), but I don't know much about its inner workings... A PR would be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants