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

Remove exception implying map or filter are ever acceptable #135

Merged
merged 1 commit into from
Feb 28, 2020

Conversation

graingert
Copy link
Contributor

@graingert graingert commented Sep 23, 2019

thankfully we now have black so multiline comprehensions are beautiful

@graingert
Copy link
Contributor Author

@adewes ^

@graingert
Copy link
Contributor Author

graingert commented Jan 29, 2020

perhaps a note to extract processing that requires multiple statements into a function:

Extract expressions that are too long or complicated to express directly within a list comprehension into a function:

def process(v):
    if v.ham == "spam":
        return 4
    if v.bacon == "eggs"
        return 7
    ...

def cond(v):
    ...

[process(x) for x in items if cond(v)]  # still preferable to map(process, filter(cond, items))

@adewes adewes merged commit 3d33a03 into quantifiedcode:master Feb 28, 2020
@graingert graingert deleted the patch-1 branch March 1, 2020 08:40
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