Skip to content

Python 2 -> 3 changes #2

Open
Open
@unode

Description

@unode

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions