On Mon, Jul 2, 2018 at 11:50 PM, Chris Barker <chris.bar...@noaa.gov> wrote:
> - keep the key function optional parameter. > - add a value function optional parameter. -- it really makes any case > where you don't want to store the whole item a lot easier. > > - 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. > > 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? > > 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. > 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. I think it's actually pretty slick -- best of both worlds? Code here: https://github.com/PythonCHB/grouper/blob/master/grouper/grouper.py -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/