marcusvolz / strava_py

Create artistic visualisations with your exercise data (Python version)
MIT License
152 stars 18 forks source link

More progress bars for slow loops, and refactor #15

Closed hugovk closed 2 years ago

hugovk commented 2 years ago

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 commented 2 years ago

Noted, many thanks Hugo!