Skip to content

Prefer list comprehensions over map and filter #971

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

Merged
merged 2 commits into from
Jan 15, 2019

Conversation

gbrova
Copy link
Contributor

@gbrova gbrova commented Jan 15, 2019

Fixes #968.

This PR removes the recommendation to use map over list comprehensions from the Structuring Your Project page.

This PR also removes most discussion about map and filter from the Code Style page, recommending instead generator functions and list comprehensions (as discussed in #968). Personally, I value opinionated and prescriptive guides when learning something new, but feel free to push back if the old material should stay.

Also made some minor edits, slightly expanded the discussion on list vs iterators, and added a couple of examples.

 - Remove emphasis on map and filter, in favor of generator expressions.
 - Move list comprehensions and generator expressions under "Short ways
   to manipulate lists" rather than "Filtering a list".
 - Add some examples.
@mpoulin mpoulin merged commit 1efc78a into realpython:master Jan 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants