[Freeipa-devel] keys[-1] idiom?

John Dennis jdennis at redhat.com
Fri Jun 8 14:56:18 UTC 2012


I frequently see this idiom in the code in plugins and pre/post callbacks:

keys[-1]

My understanding is that keys in the positional parameter list of the 
command, correct?

keys always appears in a formal parameter list with the parameter 
"options", which I believe are the keyword arguments of the command 
(i.e. *args, **kwds)

Thus keys[-1] would be the last positional parameter. What is special 
about it such that one can always reference the last positional 
parameter? (or have I misunderstood, if so please elucidate).

If keys is the positional parameter list (e.g. *args) why is is called 
"keys"? That seems really confusing because keys usually has an entirely 
different meaning (i.e. keys of a dict). Why isn't it named "args"?


-- 
John Dennis <jdennis at redhat.com>

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/




More information about the Freeipa-devel mailing list