<div dir="ltr">On Mon, Jul 2, 2018 at 11:50 PM, Chris Barker <span dir="ltr"><<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra">- keep the key function optional parameter.<br><div class="gmail_quote"><div>- add a value function optional parameter. -- it really makes any case where you don't want to store the whole item a lot easier.<br><br></div><div>- Have the default key function be itemgetter(0) and the default value function be itemgetter(1) (or some similar way to implement default support for processing an iterable of (key, value) pairs.<br><br></div><div>Having no value function and an equality default for the key function may be "common", but it's also pretty much useless -- why have a useless default?<br><br></div><div>Thinking this through now I do see that having key and value default to to the pair method means that if you specify key function, you will probably have to specify a value function as well -- so maybe that's not ideal.<br></div></div></div></div></blockquote><div><br></div><div>OK, I prototyped a class solution that defaults to key, value pairs, but you can specify a key and/or value function. and with convoluted logic, if you specify just a key, then the value defaults to the entire item. So folks will pretty much get what they expect.<br><br></div><div>I think it's actually pretty slick -- best of both worlds?<br></div><div><br></div><div>Code here:<br><br><a href="https://github.com/PythonCHB/grouper/blob/master/grouper/grouper.py">https://github.com/PythonCHB/grouper/blob/master/grouper/grouper.py</a><br></div><div><br></div><div>-CHB<br></div><br clear="all"></div><br>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R (206) 526-6959 voice<br>7600 Sand Point Way NE (206) 526-6329 fax<br>Seattle, WA 98115 (206) 526-6317 main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>