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

Fix for Python 2/3 compatibility #2342

Closed
wants to merge 1 commit into from
Closed

Fix for Python 2/3 compatibility #2342

wants to merge 1 commit into from

Conversation

rsxm
Copy link
Contributor

@rsxm rsxm commented Mar 6, 2017

In Python 2 calling keys makes a copy of the key that you can iterate over while modifying the dict.
This doesn't work in Python 3, because keys returns an iterator instead of a list.
To make it work in both Python 2 and 3, use list(d) instead of d.keys() to force a copy.

Source: http://stackoverflow.com/a/11941855

In Python 2 calling keys makes a copy of the key that you can iterate over while modifying the dict.
This doesn't work in Python 3, because keys returns an iterator instead of a list.
To make it work in both Python 2 and 3, use `list(d)` instead of d.keys() to force a copy.



Source: http://stackoverflow.com/a/11941855
@rsxm
Copy link
Contributor Author

rsxm commented Mar 6, 2017

Not sure if this is related to #2317 as the issue does not specify the Python version, but I picked up this issue when trying to migrate from 0.15.4 to 0.17.0. I'll create a seperate issue and link to this pull request.

@xrmx
Copy link
Contributor

xrmx commented Mar 6, 2017

Dup of #2320

@xrmx xrmx closed this Mar 6, 2017
@rsxm rsxm deleted the patch-1 branch March 6, 2017 10:21
@rsxm
Copy link
Contributor Author

rsxm commented Mar 6, 2017

Ha, thanks! Maybe I should rather create a pull request to remind users to check both issues and pull requests in the ISSUE_TEMPLATE.md 😃

@xrmx
Copy link
Contributor

xrmx commented Mar 6, 2017

@jr-minnaar PR clashes are not so frequest and people tend to put already checks randomly in the issue template that i won't bother doing so :)

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

Successfully merging this pull request may close these issues.

3 participants