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

NameError in list comprehension #3

Closed
cknoll opened this issue Mar 8, 2018 · 0 comments
Closed

NameError in list comprehension #3

cknoll opened this issue Mar 8, 2018 · 0 comments

Comments

@cknoll
Copy link
Owner

cknoll commented Mar 8, 2018

Reproduce:
from ipydex import IPS

def func():

    a = list(range(7))
    d = dict(zip(a, a))


    # these lines work in embedded shell
    res = [i for i in a]
    res = [1 for i in a]

    # these lines dont work in embedded shell (Name error)
    res = [d[i] for i in a]
    res = [a[i] for i in a]
    res = [a[0] for i in a]

    IPS()

func()

The background seems to be ipython/ipython#62

There, the following workarround is proposed: globals().update(locals()) (to be executed in the shell)

cknoll added a commit that referenced this issue Mar 8, 2018
@cknoll cknoll closed this as completed Mar 8, 2018
cknoll added a commit that referenced this issue Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant