Opened 2 years ago

Closed 2 years ago

#23824 closed enhancement (fixed)

py3 some care for .items

Reported by: chapoton Owned by:
Priority: major Milestone: sage-8.1
Component: python3 Keywords:
Cc: tscrim, jdemeyer, jhpalmieri, aapitzsch, fbissey Merged in:
Authors: Frédéric Chapoton Reviewers: Jeroen Demeyer
Report Upstream: N/A Work issues:
Branch: df80274 (Commits) Commit: df8027497e0976409aeaf681b023eb169f04ee3e
Dependencies: Stopgaps:

Description

as another step to py3, issue found using a python3 build

Change History (9)

comment:1 Changed 2 years ago by chapoton

  • Branch set to u/chapoton/23824
  • Cc tscrim jdemeyer jhpalmieri aapitzsch fbissey added
  • Commit set to 04f20598206d8a5d89c682d876de2fd70809be3d
  • Status changed from new to needs_review

New commits:

04f2059py3 fixing calls of .items()[...]

comment:2 Changed 2 years ago by jdemeyer

  • Status changed from needs_review to needs_work

I think it is better style to write

            (e, c), = d.items()

instead of

            e, c = next(iter(d.items()))

to get the unique element of some iterator.

comment:3 follow-up: Changed 2 years ago by chapoton

but d.items() is not an iterator in python3

comment:4 in reply to: ↑ 3 Changed 2 years ago by jdemeyer

Replying to chapoton:

but d.items() is not an iterator in python3

I meant iterable and that should be case for Python 2 and Python 3.

And for list(sequence)[:n], I would suggest instead islice(sequence, n) (with from itertools import islice)

comment:5 Changed 2 years ago by git

  • Commit changed from 04f20598206d8a5d89c682d876de2fd70809be3d to df8027497e0976409aeaf681b023eb169f04ee3e

Branch pushed to git repo; I updated commit sha1. New commits:

df80274trac 23824 better syntax

comment:6 Changed 2 years ago by chapoton

  • Status changed from needs_work to needs_review

thanks, done

comment:7 Changed 2 years ago by jdemeyer

  • Reviewers set to Jeroen Demeyer

Great! You can set positive review if it passes tests.

comment:8 Changed 2 years ago by chapoton

  • Status changed from needs_review to positive_review

bot is green enough

comment:9 Changed 2 years ago by vbraun

  • Branch changed from u/chapoton/23824 to df8027497e0976409aeaf681b023eb169f04ee3e
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.