Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-07 Thread Eric V. Smith
On 1/7/2019 10:15 AM, Chris Angelico wrote: On Mon, Jan 7, 2019 at 11:11 PM Oscar Benjamin wrote: On Mon, 7 Jan 2019 at 09:27, Chris Angelico wrote: On Mon, Jan 7, 2019 at 7:11 PM Anders Hovmöller wrote: This proposal is basically about introducing goto to the language. A bit hyperbolic

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread Steven D'Aprano
On Mon, Jan 07, 2019 at 02:01:34PM +, Jonathan Fine wrote: > Finally, I suggest that we might learn from > == > Fix some special cases in Fractions? > https://mail.python.org/pipermail/python-ideas/2018-August/053083.html > == I remember that thread from August, and I've just re-read the

Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-07 Thread Chris Angelico
On Mon, Jan 7, 2019 at 11:11 PM Oscar Benjamin wrote: > > On Mon, 7 Jan 2019 at 09:27, Chris Angelico wrote: > > > > On Mon, Jan 7, 2019 at 7:11 PM Anders Hovmöller wrote: > > > > > > > > > > This proposal is basically about introducing goto to the language. > > > > > > A bit hyperbolic but I

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread Steven D'Aprano
On Mon, Jan 07, 2019 at 10:05:19AM -0500, David Mertz wrote: > On Mon, Jan 7, 2019 at 6:50 AM Steven D'Aprano wrote: > > > > I'll provide a suggested batch on the bug. It will simply be a wholly > > > different implementation of median and friends. > > > > I ask for a documentation patch and

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread David Mertz
On Mon, Jan 7, 2019 at 6:50 AM Steven D'Aprano wrote: > > I'll provide a suggested batch on the bug. It will simply be a wholly > > different implementation of median and friends. > > I ask for a documentation patch and you start talking about a whole new > implementation. Huh. > A new

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread Guido van Rossum
On Mon, Jan 7, 2019 at 8:39 AM Steven D'Aprano wrote: > Its not a bug in median(), because median requires the data implement a > total order. Although that isn't explicitly documented, it is common > sense: if the data cannot be sorted into smallest-to-largest order, how > can you decide which

Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-07 Thread Oscar Benjamin
On Mon, 7 Jan 2019 at 09:27, Chris Angelico wrote: > > On Mon, Jan 7, 2019 at 7:11 PM Anders Hovmöller wrote: > > > > > > > This proposal is basically about introducing goto to the language. > > > > A bit hyperbolic but I agree that it has the same problem as goto. But the > > specific

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread Jonathan Fine
Happy New Year (off topic). Based on a quick review of the python docs, the bug report, PEP 450 and this thread, I suggest 1. More carefully draw attention to the NaN feature, in the documentation for existing Python versions. 2. Consider revising statistics.py so that it raises an exception,

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread Steven D'Aprano
On Mon, Jan 07, 2019 at 01:34:47AM -0500, David Mertz wrote: > > I'm not opposed to documenting this better. Patches welcome :-) > > > > I'll provide a suggested batch on the bug. It will simply be a wholly > different implementation of median and friends. I ask for a documentation patch and

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread David Mertz
On Mon, Jan 7, 2019 at 12:19 PM David Mertz wrote: > Under a partial ordering, a median may not be unique. Even under a total > ordering this is true if some subset of elements form an equivalence > class. But under partial ordering, the non-uniqueness can get much weirder. > I'm sure with

Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-07 Thread Barry
> On 7 Jan 2019, at 03:06, Richard Damon wrote: > > For something like reading options from a config file, I would use a > call that specifies the key and a value to use if the key isn't present, > and inside that function I might use a try to handle any exception > caused when processing the

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread David Mertz
On Mon, Jan 7, 2019, 11:38 AM Steven D'Aprano Its not a bug in median(), because median requires the data implement a > total order. Although that isn't explicitly documented, it is common sense: > if the data cannot be sorted into smallest-to-largest order, how can you > decide which value is in

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread MRAB
On 2019-01-07 16:34, Steven D'Aprano wrote: On Mon, Jan 07, 2019 at 10:05:19AM -0500, David Mertz wrote: [snip] It's not hard to manually check for NaNs and generate those in your own code. That is correct, but by that logic, we don't need to support *any* form of NAN handling at all. It is

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread David Mertz
This callback idea feels way over-engineered for this module. It would absolutely make sense in a more specialized numeric or statistical library. But `statistics` feels to me like it should be only simple and basic operations, with very few knobs attached. On Mon, Jan 7, 2019, 2:36 PM MRAB On

Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-07 Thread Richard Damon
On 1/7/19 3:38 PM, Barry wrote: > >> On 7 Jan 2019, at 03:06, Richard Damon wrote: >> >> For something like reading options from a config file, I would use a >> call that specifies the key and a value to use if the key isn't present, >> and inside that function I might use a try to handle any

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread Steven D'Aprano
On Mon, Jan 07, 2019 at 07:35:45PM +, MRAB wrote: > Could the functions optionally accept a callback that will be called > when a NaN is first seen? > > If the callback returns False, NaNs are suppressed, otherwise they are > retained and the function returns NaN (or whatever). That's an

Re: [Python-ideas] Fixed point format for numbers with locale based separators

2019-01-07 Thread Łukasz Stelmach
Dnia 6 stycznia 2019 o 01:48 "Eric V. Smith" napisał(a): > On 1/5/2019 3:03 PM, Łukasz Stelmach wrote: >> Barry Scott writes: >>> On Friday, 4 January 2019 14:57:53 GMT Łukasz Stelmach wrote: I would like to present two pull requests[1][2] implementing fixed point presentation of

Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-07 Thread Chris Angelico
On Mon, Jan 7, 2019 at 7:11 PM Anders Hovmöller wrote: > > > > This proposal is basically about introducing goto to the language. > > A bit hyperbolic but I agree that it has the same problem as goto. But the > specific suggested solution is not something we should be restricted so > rigidly to

Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-07 Thread Anders Hovmöller
> You mean like this? > > https://docs.python.org/3/library/contextlib.html#contextlib.suppress Hah. Exactly. Maybe that is what the OP wanted in the first place? It's always surprising how much stuff is in the standard lib even after all these years! Thanks for this. / Anders

Re: [Python-ideas] Possible PEP regarding the use of the continue keyword in try/except blocks

2019-01-07 Thread Anders Hovmöller
> This proposal is basically about introducing goto to the language. A bit hyperbolic but I agree that it has the same problem as goto. But the specific suggested solution is not something we should be restricted so rigidly to in this discussion. One could for example see another solution to

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread Steven D'Aprano
(By the way, I'm not outright disagreeing with you, I'm trying to weigh up the pros and cons of your position. You've given me a lot to think about. More below.) On Sun, Jan 06, 2019 at 11:31:30PM -0800, Nathaniel Smith wrote: > On Sun, Jan 6, 2019 at 11:06 PM Steven D'Aprano wrote: > > I'm

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread Antoine Pitrou
On Sun, 6 Jan 2019 19:40:32 -0800 Stephan Hoyer wrote: > On Sun, Jan 6, 2019 at 4:27 PM Steven D'Aprano wrote: > > > I propose adding a "nan_policy" keyword-only parameter to the relevant > > statistics functions (mean, median, variance etc), and defining the > > following policies: > > > >