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

Python 2 -> 3 changes #2

Open
10 tasks
unode opened this issue Mar 23, 2020 · 1 comment
Open
10 tasks

Python 2 -> 3 changes #2

unode opened this issue Mar 23, 2020 · 1 comment

Comments

@unode
Copy link

unode commented Mar 23, 2020

We have some legacy references that are somewhat confusing for newcomers. Listing them here for later edit.

  • The cheat sheet claims that myDict.keys() returns a list of keys when in fact it returns a view in py3
  • There are references to [range()] vs list(range()) which produce different results under Python 3 and were found to be confusing.
  • https://pyformat.info as a good resource for .format() and f-strings.
  • Relying too much on index based access can have performance impacts - mention for a, b in zip(as, bs) as alternative. Explain zip() returns generator/iterator.
  • Avoid use of .keys() in for loops.
  • Update bokeh imports - from bokeh.io import gridplot is now from bokeh.layouts import gridplot
  • Introduce with and clarify that closing files is important.
  • There are some cases of \ at the end of the line to visual line breaking. This was confusing in the context of \.format().
  • The text mentions pip install but since we are using anaconda we should probably install things with conda ...
  • A few people ran into the situation where they accidentally emptied one of the provided files by opening it in 'w' mode. Can we maybe make this more robust to avoid accidentally deleting the file or making a copy to simplify the process of recovering from this mistake.
@WhoIsJack
Copy link

  • The cheat sheet claims that myDict.keys() returns a list of keys when in fact it returns a view in py3

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

2 participants