On Thursday, 1 February 2018 at 20:18:37 UTC, Ola Fosheim Grøstad
wrote:
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote:
def aget(d, k1, k2):
return d.get(k1, {}).get(k2, '')
aa = ['ver', 'rev']
kk = set(chain(srv1.keys(), srv2.keys()))
dd = [dict(_name=k,
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote:
def aget(d, k1, k2):
return d.get(k1, {}).get(k2, '')
aa = ['ver', 'rev']
kk = set(chain(srv1.keys(), srv2.keys()))
dd = [dict(_name=k, **{a + str(i): aget(d, k, a) for a in
aa for i, d in enumerate([srv1,
On Thursday, 1 February 2018 at 11:59:23 UTC, Russel Winder wrote:
On Mon, 2018-01-15 at 21:13 +, lobo via Digitalmars-d-learn
wrote:
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote:
> A workmate has recently shown this piece of code to show how
> nice Python is (we are mostly C
On Mon, 2018-01-15 at 21:13 +, lobo via Digitalmars-d-learn wrote:
> On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote:
> > A workmate has recently shown this piece of code to show how
> > nice Python is (we are mostly C and growing C++ shop):
> >
> > [...]
>
> Well if that is what
On Mon, 2018-01-15 at 20:27 +, Igor Shirkalin via Digitalmars-d-
learn wrote:
> On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote:
> > A workmate has recently shown this piece of code to show how
> > nice Python is (we are mostly C and growing C++ shop):
> > dd = [dict(_name=k,
On 15.01.2018 20:05, xenon325 wrote:
I think, most clear code would be with tripple `foreach`, so I'll go
with that. But probably someone will come up with something better and
range-ier.
Suggestion are welcome!
import std.stdio, std.algorithm, std.range, std.array, std.conv,
std.json,
On 15.01.2018 22:51, Timon Gehr wrote:
auto aa(R)(R r){
typeof(r.front[1])[typeof(r.front[0])] a;
foreach(x;r) a[x[0]] = x[1];
return a;
}
Actually, better to use std.array.assocArray.
import std.stdio, std.algorithm, std.range, std.array, std.conv,
std.json, std.typecons;
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote:
I think, most clear code would be with tripple `foreach`, so
I'll go with that. But probably someone will come up with
something better and range-ier.
I will admit clarity has suffered, but I like the brevity:
import std.json :
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote:
A workmate has recently shown this piece of code to show how
nice Python is (we are mostly C and growing C++ shop):
[...]
Well if that is what they can do in Python I'd hate to see their
C++! They have done a great job making
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote:
A workmate has recently shown this piece of code to show how
nice Python is (we are mostly C and growing C++ shop):
dd = [dict(_name=k, **{a + str(i): aget(d, k, a) for a in
aa for i, d in enumerate([srv1, srv2])}) for k in
A workmate has recently shown this piece of code to show how nice
Python is (we are mostly C and growing C++ shop):
import json
from itertools import chain
srv1 = {'acs': {'ver': '1.2.3', 'rev': '6f2260d'}, 'cms':
{'ver': '4.5', 'rev': 'b17a67e'}, 'ots': {'ver': '6.7.80', 'rev':
11 matches
Mail list logo