[Python-ideas] Re: Multiple arguments to str.partition and bytes.partition

2023-01-08 Thread Stephen J. Turnbull
Steven D'Aprano writes: > On Sat, Jan 07, 2023 at 10:48:48AM -0800, Peter Ludemann wrote: > > You can get almost the same result using pattern matching. For example, > > your > > "foo:bar;baz".partition(":", ";") > > can be done by a well-known matching idiom: > > re.match(r'([^:]*):([^;]*)

[Python-ideas] Re: Multiple arguments to str.partition and bytes.partition

2023-01-08 Thread James Addison via Python-ideas
On Sun, 8 Jan 2023 at 03:44, Steven D'Aprano wrote: > > Keep it nice and simple: provided with multiple separators, `partition` > will split the string on the first separator found in the source string. > > In other words, `source.partition(a, b, c, d)` will split on a /or/ b > /or/ c /or/ d, whic

[Python-ideas] Re: Multiple arguments to str.partition and bytes.partition

2023-01-08 Thread Barry Scott
> On 8 Jan 2023, at 10:10, James Addison via Python-ideas > wrote: > > On Sun, 8 Jan 2023 at 03:44, Steven D'Aprano wrote: >> >> Keep it nice and simple: provided with multiple separators, `partition` >> will split the string on the first separator found in the source string. >> >> In othe

[Python-ideas] Re: Multiple arguments to str.partition and bytes.partition

2023-01-08 Thread James Addison via Python-ideas
On Sun, 8 Jan 2023 at 13:20, Barry Scott wrote: > Maybe combine the ideas by allowing a tuple where a string is used. > 'a=b;c'.partition('=', (':',';')) => ('a', '=', b, ';', 'c') I like that idea - and it seems to fit neatly with the existing partition contract: the inclusion of the matched-de

[Python-ideas] Re: Multiple arguments to str.partition and bytes.partition

2023-01-08 Thread Steven D'Aprano
On Sun, Jan 08, 2023 at 05:30:30PM +0900, Stephen J. Turnbull wrote: > Steven D'Aprano writes: > > > On Sat, Jan 07, 2023 at 10:48:48AM -0800, Peter Ludemann wrote: > > > You can get almost the same result using pattern matching. For example, > your > > > "foo:bar;baz".partition(":", ";") > >

[Python-ideas] Re: Multiple arguments to str.partition and bytes.partition

2023-01-08 Thread James Addison via Python-ideas
On Sun, 8 Jan 2023 at 08:32, Stephen J. Turnbull wrote: > > Steven D'Aprano writes: > > > On Sat, Jan 07, 2023 at 10:48:48AM -0800, Peter Ludemann wrote: > > > You can get almost the same result using pattern matching. For example, > your > > > "foo:bar;baz".partition(":", ";") > > > can be d

[Python-ideas] Re: Multiple arguments to str.partition and bytes.partition

2023-01-08 Thread Barry Scott
On 08/01/2023 17:06, James Addison wrote: On Sun, 8 Jan 2023 at 13:20, Barry Scott wrote: Maybe combine the ideas by allowing a tuple where a string is used. 'a=b;c'.partition('=', (':',';')) => ('a', '=', b, ';', 'c') I like that idea - and it seems to fit neatly with the existing partition

[Python-ideas] Re: Multiple arguments to str.partition and bytes.partition

2023-01-08 Thread dn
On 08/01/2023 23.10, James Addison via Python-ideas wrote: On Sun, 8 Jan 2023 at 03:44, Steven D'Aprano wrote: Keep it nice and simple: provided with multiple separators, `partition` will split the string on the first separator found in the source string. In other words, `source.partition(a,