Re: [Python-ideas] Sorted lists

2019-04-10 Thread Brice Parent
It surely would be helpful. I still find it a bit too single-case oriented. Maybe having an equivalent __sorting_algo__ property with a value of the current sorting algorithm would be more general? There could be a SortingAlgo base class, which could be extended into classes like:  - SortingAlg

[Python-ideas] Starap function exists but it seems there's not such thing as "doublestarmap"

2019-04-10 Thread Krokosh Nikita
Hello. I have a following question: How come there's no such thing in Python like starmap but which unpacks dicts as kwargs for fuction? For example I have a format string like "{param1}, {param2}" and want to get results passing list of dicts for it's .format(). Of course I can do that with

Re: [Python-ideas] Starap function exists but it seems there's not such thing as "doublestarmap"

2019-04-10 Thread Anders Hovmöller
I don't really understand. You can do: '{a} {b}'.format(**{'a': 1}, **{'b': 2}) Is that what you want? > On 10 Apr 2019, at 11:09, Krokosh Nikita wrote: > > Hello. I have a following question: How come there's no such thing in Python > like starmap but which unpacks dicts as kwargs for fuctio

Re: [Python-ideas] Starap function exists but it seems there's not such thing as "doublestarmap"

2019-04-10 Thread Krokosh Nikita
I need smth like starstarmap('{a} / {b}/ {c}'.format, [{a:1, b:2, c:3}, {a:4, b:5, c:6}, ...]) On 4/10/19 7:48 PM, Anders Hovmöller wrote: I don't really understand. You can do: '{a} {b}'.format(**{'a': 1}, **{'b': 2}) Is that what you want? On 10 Apr 2019, at 11:09, Krokosh Nikita wrote:

Re: [Python-ideas] Starap function exists but it seems there's not such thing as "doublestarmap"

2019-04-10 Thread Robert Vanden Eynde
robertvandeneynde.be Le mer. 10 avr. 2019 à 12:55, Krokosh Nikita a écrit : > I need smth like starstarmap('{a} / {b}/ {c}'.format, [{a:1, b:2, c:3}, > {a:4, b:5, c:6}, ...]) > That's def starstarmap(f, it): return (f(**x) for x in it) That looks like a recipe, not a basis function ^^ _

Re: [Python-ideas] Starap function exists but it seems there's not such thing as "doublestarmap"

2019-04-10 Thread Anders Hovmöller
> On 10 Apr 2019, at 11:55, Krokosh Nikita wrote: > > I need smth like starstarmap('{a} / {b}/ {c}'.format, [{a:1, b:2, c:3}, {a:4, > b:5, c:6}, ...]) Seems overly specific. Why not merge the dicts then call formal like normal? >> On 4/10/19 7:48 PM, Anders Hovmöller wrote: >> I don't really

Re: [Python-ideas] Starap function exists but it seems there's not such thing as "doublestarmap"

2019-04-10 Thread Serhiy Storchaka
10.04.19 12:55, Krokosh Nikita пише: I need smth like starstarmap('{a} / {b}/ {c}'.format, [{a:1, b:2, c:3}, {a:4, b:5, c:6}, ...]) Use the format_map method of str. >>> list(map('{a} / {b}/ {c}'.format_map, [{'a':1, 'b':2, 'c':3}, {'a':4, 'b':5, 'c':6}])) ['1 / 2/ 3', '4 / 5/ 6'] _

[Python-ideas] Exception for developer errors?

2019-04-10 Thread Stefano Borini
I occasionally found situations where I want to raise an exception for errors that can only arise because the developer made a mistake, for example: - an abstract method is supposed to be reimplemented and its execution is supposed to leave some internal constraints of an object unchanged, but the

Re: [Python-ideas] Exception for developer errors?

2019-04-10 Thread Elazar
You have AssertionError for that. Elazar בתאריך יום ה׳, 11 באפר׳ 2019, 1:10, מאת Stefano Borini ‏< [email protected]>: > I occasionally found situations where I want to raise an exception for > errors that can only arise because the developer made a mistake, for > example: > > - an abstra

Re: [Python-ideas] Exception for developer errors?

2019-04-10 Thread Jeroen Demeyer
On 2019-04-11 00:09, Stefano Borini wrote: I occasionally found situations where I want to raise an exception for errors that can only arise because the developer made a mistake, for example: I use AssertionError for this. An assertion failure means "this is a bug", so that seems the right cho

Re: [Python-ideas] Exception for developer errors?

2019-04-10 Thread Stefano Borini
That's quite a good idea, but then I think it should be more explicit in the documentation that the purpose goes beyond the assert statement failure. I've never seen AssertionError raised manually. On Wed, 10 Apr 2019 at 23:15, Jeroen Demeyer wrote: > > On 2019-04-11 00:09, Stefano Borini wrote:

Re: [Python-ideas] Exception for developer errors?

2019-04-10 Thread Chris Angelico
On Thu, Apr 11, 2019 at 8:15 AM Jeroen Demeyer wrote: > > On 2019-04-11 00:09, Stefano Borini wrote: > > I occasionally found situations where I want to raise an exception for > > errors that can only arise because the developer made a mistake, for > > example: > > I use AssertionError for this. A

Re: [Python-ideas] Exception for developer errors?

2019-04-10 Thread Cameron Simpson
On 10Apr2019 23:09, Stefano Borini wrote: I occasionally found situations where I want to raise an exception for errors that can only arise because the developer made a mistake, for example: - an abstract method is supposed to be reimplemented and its execution is supposed to leave some interna