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

More progress bars for slow loops, and refactor #15

Merged
merged 2 commits into from
Feb 14, 2022

Conversation

hugovk
Copy link
Collaborator

@hugovk hugovk commented Feb 14, 2022

Also in Python we generally prefer to iterate over objects in a list (or tuple, or other so-called "iterable") rather than using an index of range(len(thing)).

So for example, instead of:

n = len(activities)
for i in range(n):
    print(activities[i])

This is more direct and readable:

for activity in activities:
    print(activity)

If we do need an index as well, enumerate is often used:

for i, activity in enumerate(activities):
    print(i, activity)

@marcusvolz marcusvolz merged commit 0082e88 into marcusvolz:main Feb 14, 2022
@marcusvolz
Copy link
Owner

Noted, many thanks Hugo!

@hugovk hugovk deleted the more-progress-bars branch February 14, 2022 11:37
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