Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-16 Thread smarie
(for some reason google groups has accepted the message but the mailing list rejected it. Re-posting it, sorry for the inconvenience) Le mardi 28 novembre 2017 04:22:13 UTC+1, Nathan Schneider a écrit : > > > I think it would be interesting to investigate how assert statements are > used in the

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-16 Thread Serhiy Storchaka
16.01.18 11:38, smarie пише: You can find my attempt to do that in the valid8 project https://smarie.github.io/python-valid8 , with the 'assert_valid(...)' function. With the current language limitations I could not define something as simple as 'validat

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-16 Thread Steven D'Aprano
On Tue, Jan 16, 2018 at 01:38:25AM -0800, smarie wrote: > Typically ‘assert isfinite(x)‘ is today a good example of what is wrong: > >1. it can be disabled globally by end-users even if the lib developer >does not want it, That's not a bug, or even a problem ("wrong"), it is the very

[Python-ideas] PEP 557 Dataclasses evolution: supporting implicit field creation with __init__ signature introspection

2018-01-16 Thread smarie
(my first post seems to have been accepted by google groups but rejected by the mailing list. The first repost attempt was completely destructured by outlook > Reposting a 2d time… VERY sorry for the inconvenience, I’m not familiar with google groups) Hello there I recently found out that whi

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-16 Thread smarie
Le mardi 16 janvier 2018 16:37:29 UTC+1, smarie a écrit : > > > validate is_foo_compliant(x) or is_bar_compliant(x) > ValidationError(message) > This was a typo in this case since we use the base ValidationError it even would simplify to validate is_foo_compliant(x) or is_bar_com

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-16 Thread smarie
Le mardi 16 janvier 2018 11:24:34 UTC+1, Steven D'Aprano a écrit : > > That's not a bug, or even a problem ("wrong"), it is the very purpose of > assert. Assertions are intended to allow the end user to disable the > checks. > > If you, the developer, don't want a check to be disabled, then you

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-16 Thread Paul Moore
Grr, Google Groups gateway messes up reply-to. Apologies to anyone who gets a double-post, please can posters ensure that reply-to is set to the list, and *not* to the Google Groups gateway? Thanks. Paul On 16 January 2018 at 15:54, Paul Moore wrote: > On 16 January 2018 at 15:37, smarie > wrote

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-16 Thread smarie
Thanks Paul Le mardi 16 janvier 2018 16:56:57 UTC+1, Paul Moore a écrit : > > > Why does this need to be a statement at all? Unlike assert, it's > > always executed, so it can be defined as a simple function > Very good point. Actually that's what I already provide in valid8 with the assert_val

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-16 Thread Paul Moore
I fixed the reply-to this time, looks like you're still getting messed up by Google Groups. On 16 January 2018 at 16:25, smarie wrote: > Let's consider this example where users want to define on-the-fly one of the > validation functions, and combine it with another with a 'or': > > assert_val

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-16 Thread Paul Moore
On 16 January 2018 at 17:36, Sylvain MARIE wrote: > (trying with direct reply this time) > >> Why do you do this? What's the requirement for delaying evaluation of the >> condition? > > Thanks for challenging my poorly chosen examples :) > > The primary requirement is about *catching* > unwanted

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-16 Thread Juancarlo Añez
Perhaps the OP can look into Python macro libraries to get the wanted syntax? https://github.com/lihaoyi/macropy On Tue, Jan 16, 2018 at 2:35 PM, Paul Moore wrote: > On 16 January 2018 at 17:36, Sylvain MARIE > wrote: > > (trying with direct reply this time) > > > >> Why do you do this? What's

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2018-01-16 Thread Steven D'Aprano
On Tue, Jan 16, 2018 at 07:37:29AM -0800, smarie wrote: [...] > > The problem with a statement called "validate" is that it will break a > > huge number of programs that already include functions and methods using > > that name. > > > > You definitely make a point here. But that would be the ca

Re: [Python-ideas] Support WHATWG versions of legacy encodings

2018-01-16 Thread Stephen J. Turnbull
Soni L. writes: > This is surprising to me because I always took those encodings to > have those fallbacks [to raw control characters]. ISO-8859-1 implementations do, for historical reasons AFAICT. And they frequently produce mojibake and occasionally wilder behavior. Most legacy encodings don

Re: [Python-ideas] Support WHATWG versions of legacy encodings

2018-01-16 Thread Stephen J. Turnbull
Random832 writes: > There are plenty of standard encodings that do have actual > representations of the control characters. My complaint was not about coded character sets that don't conform to ISO 2022's conventions about control vs. graphic blocks, especially in the C1 block. It was about pr