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'([^:]*):([^;]*)
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
> 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
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
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(":", ";")
> >
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
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
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,