Q:

How is d.get used by max()?

The d.get method(?) is working fabulously for me to find the max of a value in a dictionary while returning the key. But I can't seem to understand or find any explanation for how d.get operates. Is far as I can tell: max() iterates over an iterable and returns the iteration of greatest value. When iterating over a dict, this defaults to assessing the max key.  
My confusion comes from the difference between d.get and d.get(key). How can you call a method without ()? I'm not sure how else to investigate this. 
foo = max(d, key = d.get)
weights = {
 95: 0.0,
 96: 0.0,
 97: 0.30793650793650795,
 98: 0.0,
 99: 0.0,
 100: 0.0,
 101: 0.48095238095238096,
 102: 0.0,
 103: 0.0,
 104: 0.49523809523809526,
 105: 0.0}

heaviest = max(weights, key = weights.get)
--> 104  

Using the optional argument to max() one can sort by the value and return the key. I just don't understand what is being assigned to the key argument.
Thanks all.

A:

weights.get is a function that returns a value for the corresponding key in weights. When max looks for the largest value, it uses the return value of the key argument, passing in the input as an argument.
This code:
heaviest = max(weights, key=weights.get)

is equivalent to:
heaviest = max(weights, key=lambda k: weights.get(k))

or even more explicitly:
def fetchVal(key):
    return weights.get(key) # same as weights[key]

heaviest = max(weights, key=fetchVal)

When you pass weights into max, it iterates over the keys of the dictionary. Basically, with max(weights, key=weights.get), you are saying: Give me the maximum key of weights; however, instead of using the value of the key itself to determine the max, use the corresponding value in weights.

