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

2022-06-18 Thread MRAB
On 2022-06-18 21:55, Jonathan Slenders wrote: Good catch! One correction here, I somewhat mixed up the benchmarks. I forgot both projects of mine required support for universal line endings exactly like splitlines() does this out of the box. That requires a more complex regex pattern. I was

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

2022-06-20 Thread MRAB
On 2022-06-20 16:12, Christopher Barker wrote: Hmm - I’m a bit confused about how you handle mixed / multiple line endings. If you use splitlines(), then it will remove the line endings, so if there are two-char line endings, then you’ll get off by one errors, yes? I would think you could

[Python-ideas] Re: Bare wildcard in de-structuring to ignore remainder and stop iterating (restart)

2022-06-20 Thread MRAB
On 2022-06-20 15:05, Chris Angelico wrote: On Mon, 20 Jun 2022 at 21:11, Jonathan Fine wrote: Hi Some have liked adding a new syntax a, b, ... = iterable to mean consume two items from the iterable. However, a, b, Ellipsis = iterable has a different meaning (at least in Python 3.8).

[Python-ideas] Re: Time to relax some restrictions on the walrus operator?

2022-05-08 Thread MRAB
On 2022-05-08 13:44, Chris Angelico wrote: On Sun, 8 May 2022 at 22:09, Valentin Berlier wrote: A while ago there was a discussion about allowing "match" patterns for the walrus operator. This would cover iterable unpacking as you suggested along with all the patterns allowed in match

[Python-ideas] Re: Time to relax some restrictions on the walrus operator?

2022-05-08 Thread MRAB
On 2022-05-08 11:50, Steven D'Aprano wrote: I don't have an opinion one way or the other, but there is a discussion on Discourse about the walrus operator: https://discuss.python.org/t/walrus-fails-with/15606/1 Just a quick straw poll, how would people feel about relaxing the restriction on

[Python-ideas] Re: Combinations of keywords

2023-02-21 Thread MRAB
On 2023-02-21 11:26, Steven D'Aprano wrote: [snip] If your code blocks are a single statement, you can write: try: import windows_module except ImportError: import unix_module but most people will say that is ugly and be spread out: try: import windows_module

[Python-ideas] Re: Allowing `str.format` to format one or more parameters instead of all parameters

2023-04-26 Thread MRAB
On 2023-04-26 17:41, Alexandre Brault wrote: On 2023-04-26 11:03 a.m., MRAB wrote: On 2023-04-26 02:16, Joao S. O. Bueno wrote: On Sat, Apr 22, 2023 at 10:06 AM Damian Cross <mailto:damnedbo...@gmail.com>> wrote:     That would have the effect that every use of str.format for

[Python-ideas] Re: Allowing `str.format` to format one or more parameters instead of all parameters

2023-04-26 Thread MRAB
On 2023-04-26 02:16, Joao S. O. Bueno wrote: On Sat, Apr 22, 2023 at 10:06 AM Damian Cross > wrote: That would have the effect that every use of str.format for everyone would start producing partially-formatted strings if an argument is accidentally

[Python-ideas] Re: Allowing `str.format` to format one or more parameters instead of all parameters

2023-04-28 Thread MRAB
On 2023-04-28 15:25, Matsuoka Takuo wrote: What if it's done not by format method but by a separete method, say, format_partially or something? The method is different from format also in that it should leave "{{" and "}}" unaltered. On Fri, 28 Apr 2023 at 00:05, Matthias Görgens wrote:

[Python-ideas] Re: Allowing `str.format` to format one or more parameters instead of all parameters

2023-04-29 Thread MRAB
On 2023-04-29 08:31, Matsuoka Takuo wrote: On Sat, 29 Apr 2023 at 00:52, MRAB wrote: What happens if you do '{open}...{close}'.partial_format(open='{close}'? You get '{close}...{close}', and you're going to have a problem using that as a format string and replacing only the second '{close

[Python-ideas] Re: dict method to retrieve a key from a value

2023-07-02 Thread MRAB
On 2023-07-02 17:14, Stephen J. Turnbull wrote: MRAB writes: > I would hope that if the maintainer knew that the package was on > the curated list, they would let the list know if they were going > to stop maintaining it. That would be part of being on the list - > informin

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-17 Thread MRAB
On 2023-07-17 18:10, Dom Grigonis wrote: It does exactly the same as the C version and is more readable.  Or am I missing something? My point is exactly that it is not easily readable compared to C version. Also, unnecessarily verbose. The order of components is rather awkward. I came to

[Python-ideas] Re: @lazy decorator an alternative to functools.partial ?

2023-05-18 Thread MRAB
On 2023-05-19 00:54, Greg Ewing wrote: On 19/05/23 4:16 am, Christopher Barker wrote: The problem with "batteries included" is that what exactly is a battery is hard to define, and everyone has a different opinion about it. To my mind, "batteries included" means you can do *something* useful

[Python-ideas] Re: else without except

2023-06-30 Thread MRAB
On 2023-06-30 14:55, Daniel Walker wrote: As most of you probably know, you can use else with try blocks: try:     do_stuff() except SomeExceptionClass:    handle_error() else:    no_error_occurred() Here, no_error_occurred will only be called if do_stuff() didn't raise an exception.

[Python-ideas] Re: dict method to retrieve a key from a value

2023-07-01 Thread MRAB
On 2023-07-01 11:22, Paul Moore wrote: On Sat, 1 Jul 2023 at 07:09, Christopher Barker > wrote: So I think light curation would help a lot. [*] I'd be completely in favour of someone setting up a curated package index. You could probably use the Warehouse

[Python-ideas] Re: dict method to retrieve a key from a value

2023-07-02 Thread MRAB
On 2023-07-02 06:59, Chris Angelico wrote: On Sun, 2 Jul 2023 at 15:48, Christopher Barker wrote: Only re (the one in the stdlib)? What if you want PCREs - there's no package called "pcre" but there's "pcre2", "python-pcre", and probably others. And are those three (and others?) actually

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-13 Thread MRAB
On 2023-06-13 16:42, Chris Angelico wrote: On Wed, 14 Jun 2023 at 01:07, BoppreH via Python-ideas wrote: And I have to say I'm surprised by the responses. Does nobody else hit bugs like this and wish they were automatically detected? Nope, I've never had that happen to me, and I *have*

<    1   2   3   4