Cash_Lion Cash_Lion - 4 years ago 260
Python Question

What is keyfunc used in Python's itertools.groupby() documentation

In the documentation for itertools.groupby(),

groups = []
uniquekeys = []
data = sorted(data, key=keyfunc)


I see that keyfunc is used as the key to sort the data. What does this keyword refer to?

Answer Source

It's not a keyword. It refers to whatever function you pass to sorted as the key parameter.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download