Cell-var-from-loop warning from Pylint

StackOverflow

For the following code:

for sort_key, order in query_data["sort"]:
    results.sort(key=lambda k: get_from_dot_path(k, sort_key),
                 reverse=(order == -1))

Pylint reported an error:

Cell variable sort_key defined in loop (cell-var-from-loop)

Could anyone give a hint what is happening here? From pylint source code the description is:

A variable used in a closure is defined in a loop. This will result in all closures using the same value for the closed-over variable.

But I do not have a clue what it means. Could anyone give an example of the problem?





Tutorials