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

Replace for-append with generator #55

Open
Tadaboody opened this issue Jan 1, 2019 · 0 comments
Open

Replace for-append with generator #55

Tadaboody opened this issue Jan 1, 2019 · 0 comments
Labels
new This issue hasn't been looked at yet smell A new smell to report and fix

Comments

@Tadaboody
Copy link
Owner

New smell

Smelly code

li = list()
for x in other_iterable:
    # Body
    li += expr

Fixed code

def generate_li():
    # Body
    yield expr
li = list(generate_li())

Why is it smelly?

Not as smelly:tm: as other things, but in some cases it makes more sense, and more people should be aware of the possibility.

@Tadaboody Tadaboody added smell A new smell to report and fix new This issue hasn't been looked at yet labels Jan 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new This issue hasn't been looked at yet smell A new smell to report and fix
Projects
None yet
Development

No branches or pull requests

1 participant