How to imporve D-translation of these Python list comprehensions ?

Russel Winder russel at winder.org.uk
Thu Feb 1 11:57:23 UTC 2018


On Mon, 2018-01-15 at 20:27 +0000, 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, **{a + str(i): aget(d, k, a) for a in 
> > aa for i, d in enumerate([srv1, srv2])}) for k in sorted(kk)]
> 
> This is the most terrible Python code I have ever seen.
> If you know Python, could you please unroll to more readable form?

Actually I have seen worse, but… I think the way this Python code is
presented is fairly dreadful.

I am fiddling with trying to provide a better version. If people are
interested in this I can share in a while when it's ready.

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20180201/333a025a/attachment.sig>


More information about the Digitalmars-d-learn mailing list