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

py3 some care for .items #23824

Closed
fchapoton opened this issue Sep 10, 2017 · 13 comments
Closed

py3 some care for .items #23824

fchapoton opened this issue Sep 10, 2017 · 13 comments

Comments

@fchapoton
Copy link
Contributor

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

CC: @tscrim @jdemeyer @jhpalmieri @a-andre @kiwifb

Component: python3

Author: Frédéric Chapoton

Branch/Commit: df80274

Reviewer: Jeroen Demeyer

Issue created by migration from https://trac.sagemath.org/ticket/23824

@fchapoton fchapoton added this to the sage-8.1 milestone Sep 10, 2017
@fchapoton
Copy link
Contributor Author

New commits:

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

@fchapoton
Copy link
Contributor Author

Branch: u/chapoton/23824

@fchapoton
Copy link
Contributor Author

Commit: 04f2059

@jdemeyer
Copy link

comment:2

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.

@fchapoton
Copy link
Contributor Author

comment:3

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

@jdemeyer
Copy link

comment:4

Replying to @fchapoton:

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)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 11, 2017

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

df80274trac 23824 better syntax

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 11, 2017

Changed commit from 04f2059 to df80274

@fchapoton
Copy link
Contributor Author

comment:6

thanks, done

@jdemeyer
Copy link

Reviewer: Jeroen Demeyer

@jdemeyer
Copy link

comment:7

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

@fchapoton
Copy link
Contributor Author

comment:8

bot is green enough

@vbraun
Copy link
Member

vbraun commented Sep 15, 2017

Changed branch from u/chapoton/23824 to df80274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants