[Python-ideas] Re: Abstract dataclasses and dataclass fields

2023-12-22 Thread Eric V. Smith via Python-ideas
On 12/21/2023 4:38 PM, Steve Jorgensen wrote: I am finding that it would be useful to be able to define a dataclass that is an abstract base class and define some of its field as abstract. As I am typing this, I realize that I could presumably write some code to implement what I'm asking for.

[Python-ideas] Re: re.match(pattern, string, require=True)

2023-10-22 Thread Eric V. Smith via Python-ideas
On 10/21/2023 8:31 PM, Chris Angelico wrote: On Sun, 22 Oct 2023 at 11:29, MRAB wrote: I think what the OP wants is to have re.match either return a match or raise an exception. Yes, and my point is that simply attempting to access an attribute will do exactly that. It's not a silent failure.

[Python-ideas] Re: Extract variable name from itself

2023-09-23 Thread Eric V. Smith via Python-ideas
On Sep 23, 2023, at 5:37 PM, Dom Grigonis wrote:It seems that my guess was correct. There was a commit, when only the first part was working:https://github.com/python/cpython/pull/13123/commits/67977672360659f203664d23cfc52b5e07e4381aSince I wrote that commit: no one is saying it’s impossible

[Python-ideas] Re: [dataclasses] add a NON_FIELDS sentinel after which all attributes are ignored.

2023-06-23 Thread Eric V. Smith via Python-ideas
On 6/23/2023 11:34 AM, Joao S. O. Bueno wrote: On Fri, Jun 23, 2023 at 12:18 PM Eric V. Smith wrote:  On Jun 23, 2023, at 9:34 AM, Joao S. O. Bueno wrote:  On Fri, Jun 23, 2023 at 2:35 AM Jelle Zijlstra wrote: El jue, 22 jun 2023 a las 8:22, Randolf

[Python-ideas] Re: [dataclasses] add a NON_FIELDS sentinel after which all attributes are ignored.

2023-06-23 Thread Eric V. Smith via Python-ideas
On Jun 23, 2023, at 9:34 AM, Joao S. O. Bueno wrote:On Fri, Jun 23, 2023 at 2:35 AM Jelle Zijlstra wrote:El jue, 22 jun 2023 a las 8:22, Randolf Scholz () escribió:Dataclasses should provide a way to ignore a type hinted attributes, and not

[Python-ideas] Re: Deprecate misleading escapes in strings

2023-02-16 Thread Eric V. Smith via Python-ideas
You should bring this up on https://discuss.python.org/c/ideas/6 , which is where ideas are discussed these days. This mailing list should be retired. I’ll mention that elsewhere. -- Eric > On Feb 16, 2023, at 9:57 AM, Arusekk wrote: > > Hi all! > > I was writing a tutorial on the

[Python-ideas] Re: Idea: Tagged strings in python

2022-12-22 Thread Eric V. Smith via Python-ideas
Jim Baker's draft PEP gives runtime behavior to tagged strings. I agree it would all be pointless if it's just hints to an editor. Sorry, I again don't have a handy link to his PEP. But it's similar in spirit to PEP 501. Eric On 12/22/2022 2:36 PM, Joao S. O. Bueno wrote: I am not

[Python-ideas] Re: Idea: Tagged strings in python

2022-12-17 Thread Eric V. Smith via Python-ideas
Jim Baker has been working on tagged strings, and Guido has a working implementation. See https://github.com/jimbaker/tagstr/issues/1 I thought Jim had a draft PEP on this somewhere, but I can’t find it. -- Eric > On Dec 17, 2022, at 11:14 AM, e...@emilstenstrom.se wrote: > > Hi everyone! >

[Python-ideas] Re: Allow more flexibility for describing bytes objects.

2022-11-23 Thread Eric V. Smith via Python-ideas
On 11/23/2022 3:02 PM, Chris Angelico wrote: On Thu, 24 Nov 2022 at 06:46, Barry Scott wrote: I have written a lot of low level protocol and IOCTL calls that cannot think of a time this would have helped me. struct is often a mean to create blocks of binary data. Long strings of binary data

[Python-ideas] Re: Void type

2022-07-27 Thread Eric V. Smith via Python-ideas
Sorry for top posting: I’m on the road. inspect.signature can help with this. -- Eric > On Jul 27, 2022, at 9:22 AM, Chris Angelico wrote: > > On Wed, 27 Jul 2022 at 22:54, Mathew Elman wrote: >> >> Chris Angelico wrote: Again, I am not pro this idea, just answering the questions

[Python-ideas] Re: Generalized deferred computation in Python

2022-06-22 Thread Eric V. Smith via Python-ideas
> On Jun 22, 2022, at 2:12 PM, Paul Moore wrote: > > On Wed, 22 Jun 2022 at 18:35, David Mertz, Ph.D. > wrote: >> >> Hi Martin, >> >> Short answer: yes, I agree. >> Slightly longer: I would be eternally grateful if you wish to contribute to >> the PEP with any such expansion of the

[Python-ideas] Re: Add a line_offsets() method to str

2022-06-18 Thread Eric V. Smith via Python-ideas
On 6/18/2022 5:34 PM, Paul Moore wrote: After all, it has the advantage of working on older versions of Python (and given that one of your use cases is Textual, I can't imagine anyone would be happy if that required Python 2.12+...) Guido's "no 2.8" shirt apparently didn't stop 2.9 through

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2022-06-17 Thread Eric V. Smith via Python-ideas
On 6/17/2022 10:53 AM, Chris Angelico wrote: The only two possible behaviours are: 1) It does the single obvious thing: n defaults to the length of items, and items defaults to an empty tuple. 2) It raises UnboundLocalError if you omit n. ... Would you prefer that I simply mandate that it be

[Python-ideas] Re: default as a keyword argument for dict.get and dict.pop

2022-06-08 Thread Eric V. Smith via Python-ideas
On 6/7/2022 4:59 PM, Chris Angelico wrote: On Wed, 8 Jun 2022 at 00:36, wrote: Hello! Do you know if there has been discussions around why is the default argument is positional only in the dict methods get and pop? I think ``` d.get(key, default=3) ``` way more readable than ```

[Python-ideas] Re: Addition to fnmatch.py

2022-06-05 Thread Eric V. Smith via Python-ideas
On 6/5/2022 1:22 PM, Benedict Verhegghe wrote: Op 5/06/2022 om 18:47 schreef David Mertz, Ph.D.: Sure, that's nice enough code and has the same big-O complexity. I suspect set difference is a little faster (by a constant multiple) because it hits C code more, but I haven't benchmarked. The