Re: [Python-ideas] Add new `Symbol` type

2018-07-06 Thread Michael Foord
On Fri, 6 Jul 2018 at 07:30, Steven D'Aprano wrote: > On Thu, Jul 05, 2018 at 02:38:47PM -0500, Flavio Curella wrote: > > More than once I've found myself wanting to create a 'sentinel' value. > The > > most common use case is to differentiate between an argument that has not > > been provided, a

Re: [Python-ideas] Where should grouping() live (was: grouping / dict of lists)

2018-07-06 Thread Cammil Taank
The way I see grouping is as an aggregation operation. As such, in my head, grouping is similar to min/max. However, if builtins are a no-go, then I feel I need to think a little outside the box: Is there a possibility that there will be desired many more aggregate functions in the near future? Is

Re: [Python-ideas] Add new `Symbol` type

2018-07-06 Thread Giampaolo Rodola'
Historically this has always been achieved by using: _default = object() def fun(arg=_default): if arg is not _default: ...which does its job just fine. If you need something like this you're typically a medium/advanced Python user so you either already know about it or you'l

Re: [Python-ideas] Where should grouping() live (was: grouping / dict of lists)

2018-07-06 Thread Steven D'Aprano
On Fri, Jul 06, 2018 at 09:49:37AM +0100, Cammil Taank wrote: > I would consider statistics > to have similarities - median, mean etc are aggregate functions. Histograms > are also doing something similar to grouping. I was thinking the same thing, but I don't think it is a good fit. Grouping re

Re: [Python-ideas] Add new `Symbol` type

2018-07-06 Thread Flavio Curella
@Nathaniel Smith: > I think the name "symbol" here is pretty confusing. It comes originally from Lisp > The thing you're talking about is what Python devs call a "sentinel" object. Thank you for clarifying. I don't know much about Lisp, and I definitely appreciate the historical context that you

Re: [Python-ideas] Where should grouping() live (was: grouping / dict of lists)

2018-07-06 Thread Chris Barker - NOAA Federal via Python-ideas
On Jul 6, 2018, at 2:10 AM, Steven D'Aprano wrote: I would consider statistics to have similarities - median, mean etc are aggregate functions. Not really, more like reduce, actually -/ you get a single result. Histograms are also doing something similar to grouping. .(Yes, a few statistic

Re: [Python-ideas] Add new `Symbol` type

2018-07-06 Thread Guido van Rossum
Thanks for an interesting discussion. I would also urge people to limit the use of such sentinels for cases where it is *really* important to distinguish between, say, f(None) and f(). In most cases using def f(arg=None) is fine, and often it is even a virtue that passing None or omitting an argume

Re: [Python-ideas] Add new `Symbol` type

2018-07-06 Thread Eric V. Smith
On 7/6/2018 11:20 AM, Flavio Curella wrote: I think this thread can be resolved as 'used unittest.mock.sentinel'. It doesn't have 'global sentinels', but I'm not convinced they are actually necessary, since `mock.sentinel` objects with the same name compare as equal. Thanks to Nathaniel, I now

Re: [Python-ideas] Add new `Symbol` type

2018-07-06 Thread Steven D'Aprano
On Thu, Jul 05, 2018 at 05:26:36PM -0700, Nathaniel Smith wrote: > I think the name "symbol" here is pretty confusing. It comes > originally from Lisp, where it's used to refer to an interned-string > data type. Even if Lisp was the first programming language to use the term for a data type (whi

Re: [Python-ideas] Fwd: grouping / dict of lists

2018-07-06 Thread Franklin? Lee
On Thu, Jul 5, 2018 at 1:23 AM, Chris Barker via Python-ideas wrote: > On Wed, Jul 4, 2018 at 6:34 AM, David Mertz wrote: > >> >> You've misunderstood part of the discussion. There are two different >> signatures being discussed/proposed for a grouping() function. >> >> The one you show we might

Re: [Python-ideas] Add `rc` to distutils.version.StrictVersion

2018-07-06 Thread Donald Stufft
You should https://packaging.pypa.io/en/latest/version/ instead of anything in distutils for handling version numbers. > On Jul 5, 2018, at 2:11 PM, Pål Grønås Drange wrote: > > StrictVersion from distutils accepts version tags like > 1.14.0 > 1.1

Re: [Python-ideas] Where should grouping() live

2018-07-06 Thread Michael Selik
On Tue, Jul 3, 2018 at 10:11 PM Chris Barker via Python-ideas < [email protected]> wrote: > * There are types of data well suited to the key function approach, and > other data not so well suited to it. If you want to support the not as well > suited use cases, you should have a value functi