[Python-ideas] Re: Remove a single warning from the warnings filter list

2021-09-02 Thread Peter Otten
On 02/09/2021 11:41, Chris Angelico wrote: On Thu, Sep 2, 2021 at 7:36 PM Peter Otten <__pete...@web.de> wrote: On 02/09/2021 04:32, Steven D'Aprano wrote: On Wed, Sep 01, 2021 at 03:40:37PM +0200, Peter Otten wrote: Instead of removing it you might add a filter to get a sim

[Python-ideas] Re: Remove a single warning from the warnings filter list

2021-09-02 Thread Peter Otten
On 02/09/2021 04:32, Steven D'Aprano wrote: On Wed, Sep 01, 2021 at 03:40:37PM +0200, Peter Otten wrote: Instead of removing it you might add a filter to get a similar effect: [...] warnings.filterwarnings("always", "woof!") Unfortunately that's too agg

[Python-ideas] Re: Remove a single warning from the warnings filter list

2021-09-01 Thread Peter Otten
On 01/09/2021 09:27, Steven D'Aprano wrote: Maybe I'm missing something, but I don't think that there is anyway to remove a warning from the warnings filter list so that it will be shown again. Example: >>> import warnings >>> warnings.warn("something happened") :1: UserWarning:

[Python-ideas] Re: NAN handling in statistics functions

2021-08-26 Thread Peter Otten
On 26/08/2021 09:36, Marc-Andre Lemburg wrote: In Python you can use a simple test for this: I think you need math.isnan(). nan = float('nan') l = [1,2,3,nan] d = {nan:1, 2:3, 4:5, 5:nan} s = set(l) nan in l True That only works with identical nan-s, and because the container omits the e

[Python-ideas] Re: Make fnmatch.filter accept a tuple of patterns

2021-03-26 Thread Peter Otten
On 24/03/2021 23:35, adelf...@gmail.com wrote: Several attempts in this thread to write "simpler" code that does this job proved to be buggy. I feel there's some ground to say that having this in the library could prevent other less talented writers make those or even bigger mistakes. I feel a

[Python-ideas] Re: dataclasses: position-only and keyword-only fields

2021-03-14 Thread Peter Otten
Speaking as someone who's not into dataclasses: This whole thread seems to be about spelling the initilizer's function signature as a class body. Have you considered going in the opposite direction, i. e. writing something like @dataclass class A: @attributes_from_signature def __init

[Python-ideas] Re: Inadequate error reporting during function call setup stage

2021-02-22 Thread Peter Otten
On 21/02/2021 23:06, Terry Reedy wrote: On 2/21/2021 12:04 PM, Paul Sokolovsky wrote: Traceback (most recent call last):    File "pseudoc_tool.py", line 91, in first_class_function_value(func, **pass_params) TypeError: print() got an unexpected keyword argument 'noann' This is not typic

[Python-ideas] Re: Introduce 100 more built-in exceptions

2020-05-01 Thread Peter Otten
M.-A. Lemburg wrote: > Hi Ram, > > I think you are confusing the exception type with the exception > reason. By adding 100 more exception types, you don't make things > easier, but instead you complicate things, since we'd all have > to memorize those 100 exception types. > > That said, enhancin

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-08 Thread Peter Otten
Richard Musil wrote: > I have found myself in an awkward situation with current (Python 3.7) JSON > module. Basically it boils down to how it handles floats. I had been hit > on this particular case: > > In [31]: float(0.6441726684570313) > Out[31]: 0.6441726684570312 > > but I guess it really doe

Re: [Python-ideas] Make "yield" inside a with statement a SyntaxError

2018-08-08 Thread Peter Otten
Ronald Oussoren via Python-ideas wrote: > It is also possible to fix the particular issue by using another with > statement, that is use: > > with contextlib.closing(read_multiple(…)) as chunks: >for contents in chunks: >… > > Automatically closing the generator at the end of the for

Re: [Python-ideas] Arguments to exceptions

2017-07-05 Thread Peter Otten
Terry Reedy wrote: > Alternate proposal: give the NameError class a .name instance method > that extracts the name from the message. This should not increase the > time to create an instance. You would then write 'err.name()' instead > of 'err.name'. For 3.6 > > def name(self): > msg = self