[Python-ideas] Re: Segmentation of string

2019-12-25 Thread Siddharth Prajosh
Why not create a new custom class which has this function there? You can use that object whenever you need the segments. This is a very rare use case and doesn't make sense to implement that in str. On Wed, 25 Dec, 2019, 09:25 python-ideas--- via Python-ideas, < [email protected]> wrote: >

[Python-ideas] Re: Segmentation of string

2019-12-25 Thread python-ideas--- via Python-ideas
See my implementation, is generic and not only for strings. It could be added to more-itertools, I suppose: https://mail.python.org/archives/list/[email protected]/message/E452LQGA3XKU5ADPTG54XP36ENXDZN2B/ ___ Python-ideas mailing list -- python-i

[Python-ideas] Re: Segmentation of string

2019-12-25 Thread python-ideas--- via Python-ideas
Excuse me again, I just relized that my algorithm was flawed. I just inserted in my function the brilliant algorithm of Mark Dickinson and now it works: import itertools as itools def segment(it, n=1): if n < 1: raise ValueError(f"Number of segment must be > 0, {n} found"

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-25 Thread python-ideas--- via Python-ideas
If I can spend my two cents, I think the fact the most of you prefer | is because is already how sets works. And IMHO it's a bit illogical, since sets also support -. So I do not understand why | was chosen instead of +. Furthermore, sets supports < operator, that gives you the false hope that se

[Python-ideas] Re: Renaming json.load()

2019-12-25 Thread python-ideas--- via Python-ideas
Well, `json` and the other modules could add another standard: `serialize` and `deserialize` As an example, this is how I deserialize from a custom class: def __init__(self, source): path = None try: # most common case: JSON string self._data_raw = js

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-25 Thread Andrew Barnert via Python-ideas
On Dec 25, 2019, at 14:57, python-ideas--- via Python-ideas wrote: First, as a side note, you seem to have configured your python-ideas-posting address with the name “python-ideas” rather than with a name that can be used to distinguish you from other people. This will make conversations confu

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-25 Thread python-ideas--- via Python-ideas
Andrew Barnert wrote: > On Dec 25, 2019, at 14:57, python-ideas--- via Python-ideas > [email protected] wrote: > > If I can spend my two cents, I think the fact the > > most of you prefer | is because is already how sets works. And IMHO it's a > > bit illogical, > > since sets also support

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-25 Thread Chris Angelico
On Thu, Dec 26, 2019 at 1:12 PM python-ideas--- via Python-ideas wrote: > > Andrew Barnert wrote: > > On Dec 25, 2019, at 14:57, python-ideas--- via Python-ideas > > [email protected] wrote: > > > If I can spend my two cents, I think the fact the > > > most of you prefer | is because is al

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-25 Thread MRAB
On 2019-12-26 02:09, python-ideas--- via Python-ideas wrote: Andrew Barnert wrote: [snip] you seem to have configured your python-ideas-posting address with the name “python-ideas” rather than with a name that can be used to distinguish you from other people. This will make conversations confu

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-25 Thread David Mertz
On Wed, Dec 25, 2019, 9:11 PM python-ideas--- via Python-ideas < [email protected]> wrote: > On the contrary, on sets you can apply union *and* difference. And since > union seems the exact contrary of difference, it's illogical that | is used > instead of +. Set union is self-evidently NO

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-25 Thread Richard Damon
On 12/25/19 10:06 PM, MRAB wrote: On 2019-12-26 02:09, python-ideas--- via Python-ideas wrote: Andrew Barnert wrote: [snip] you seem to have configured your python-ideas-posting address with the name “python-ideas” rather than with a name that can be used to distinguish you from other people

[Python-ideas] Re: Renaming json.load()

2019-12-25 Thread Siddharth Prajosh
I second that.. json.load/loads and json.dump/dumps should be more understandable.. On Thu, 26 Dec, 2019, 04:50 python-ideas--- via Python-ideas, < [email protected]> wrote: > Well, `json` and the other modules could add another standard: `serialize` > and `deserialize` > > As an example, t