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

Update Python 2/3 porting HOWTO's suggestion for dealing with map() #65436

Closed
brettcannon opened this issue Apr 15, 2014 · 3 comments
Closed
Assignees
Labels
docs Documentation in the Doc dir easy type-feature A feature request or enhancement

Comments

@brettcannon
Copy link
Member

BPO 21237
Nosy @brettcannon, @MojoVampire

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/brettcannon'
closed_at = <Date 2014-05-09.18:35:11.558>
created_at = <Date 2014-04-15.15:45:50.531>
labels = ['easy', 'type-feature', 'docs']
title = "Update Python 2/3 porting HOWTO's suggestion for dealing with map()"
updated_at = <Date 2014-05-09.18:35:11.557>
user = 'https://github.com/brettcannon'

bugs.python.org fields:

activity = <Date 2014-05-09.18:35:11.557>
actor = 'brett.cannon'
assignee = 'brett.cannon'
closed = True
closed_date = <Date 2014-05-09.18:35:11.558>
closer = 'brett.cannon'
components = ['Documentation']
creation = <Date 2014-04-15.15:45:50.531>
creator = 'brett.cannon'
dependencies = []
files = []
hgrepos = []
issue_num = 21237
keywords = ['easy']
message_count = 3.0
messages = ['216315', '216458', '218191']
nosy_count = 2.0
nosy_names = ['brett.cannon', 'josh.r']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'needs patch'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue21237'
versions = []

@brettcannon
Copy link
Member Author

In Python 2.6 and newer you can import future_builtins and use everything from there. In Python 2.5 it should be itertools.imap(). This is much cleaner than the current suggestion at https://docs.python.org/2/howto/pyporting.html#update-map-for-imbalanced-input-sequences

@brettcannon brettcannon self-assigned this Apr 15, 2014
@brettcannon brettcannon added docs Documentation in the Doc dir easy type-feature A feature request or enhancement labels Apr 15, 2014
@MojoVampire
Copy link
Mannequin

MojoVampire mannequin commented Apr 16, 2014

I think the suggestion is intended for "how do I keep Python 2 semantics in Python 3?", not "how can I write my Python 2 code so it will run equivalently in Python 3?"

It wouldn't be a bad idea to point out that you can adopt Py3 semantics initially so as to avoid surprises later on; sadly, unlike a __future__ import, if you want cross compatible code you have to do stupid stuff like:

try:
from future_builtins import *
except ImportError:
# Py3 is already the future
pass

@brettcannon
Copy link
Member Author

I never bothered to mention the iter* methods in the HOWTO, and since it becomes very obvious very fast to tweak them I'm not going to worry about it and add more complexity to the doc.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir easy type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant