Skip to content

Use list unpacking #1

@cthoyt

Description

@cthoyt

There are a lot of places where you're getting sequential elements from a list. Use unpacking to make this code more readable:

MEN2017/miscellaneous.py

Lines 74 to 75 in 1f77631

q_p = predictionListStats[0]
q_m = predictionListStats[1]

At best, this can look like:

q_p,  q_m = predictionListStats

If there are more elements in predictionListStats, then you have a couple options:

Explicit assignment

q_p,  q_m = predictionListStats[0], predictionListStats[1] 

Unpacking sliced list

q_p,  q_m = predictionListStats[0:2]

Splat Unpacking

q_p,  q_m, *_ = predictionListStats

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions