Opened 4 years ago
Closed 4 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, GitHub, GitLab) | Commit: | df8027497e0976409aeaf681b023eb169f04ee3e |
Dependencies: | Stopgaps: |
Description
as another step to py3, issue found using a python3 build
Change History (9)
comment:1 Changed 4 years ago by
- Branch set to u/chapoton/23824
- Cc tscrim jdemeyer jhpalmieri aapitzsch fbissey added
- Commit set to 04f20598206d8a5d89c682d876de2fd70809be3d
- Status changed from new to needs_review
comment:2 Changed 4 years ago by
- 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: ↓ 4 Changed 4 years ago by
but d.items() is not an iterator in python3
comment:4 in reply to: ↑ 3 Changed 4 years ago by
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 4 years ago by
- Commit changed from 04f20598206d8a5d89c682d876de2fd70809be3d to df8027497e0976409aeaf681b023eb169f04ee3e
Branch pushed to git repo; I updated commit sha1. New commits:
df80274 | trac 23824 better syntax
|
comment:7 Changed 4 years ago by
- Reviewers set to Jeroen Demeyer
Great! You can set positive review if it passes tests.
comment:8 Changed 4 years ago by
- Status changed from needs_review to positive_review
bot is green enough
comment:9 Changed 4 years ago by
- 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.
New commits:
py3 fixing calls of .items()[...]