[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 > python-ideas@python.org 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 i

[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 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: 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: 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/python-ideas@python.org/message/E452LQGA3XKU5ADPTG54XP36ENXDZN2B/ ___ Python-ideas mailing list -- python-i

[Python-ideas] Re: Add "elif" to "for_stmt" and "while_stmt"

2019-12-24 Thread python-ideas--- via Python-ideas
There's already: for i in range(j): if i > 5: ... else: ... else: ... ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://m

[Python-ideas] Re: Segmentation of string

2019-12-24 Thread python-ideas--- via Python-ideas
Excuse me, ignore my previous post, this is the correct implementation. It works for every iterable: import itertools as itools def segment(it, n=1): if n < 1: raise ValueError(f"Number of segment must be > 0") try: len_it = len(it)

[Python-ideas] Re: Segmentation of string

2019-12-24 Thread python-ideas--- via Python-ideas
import itertools as itools def segment(it, n=1): try: len_it = len(it) it_true = it except TypeError: it_true = tuple(it) len_it = len(it_true) size, rest = divmod(len_it, n) sizes = [size] * n for i in range(rest): sizes[-i] +=

[Python-ideas] Re: Add symlinks option at shutil.move parameters

2019-12-24 Thread python-ideas--- via Python-ideas
Well, I suppose it wants simlink=False. Anyway, why not change the signature of move to def move(src, dst, **kwargs): and change the call of copytree to copytree(src, real_dst, **kwargs) ? ___ Python-ideas mailing list -- python-ideas@python.org To