4 ms·
Yes - the description of writing Python as like assembling Ikea furniture is absolutely spot-on. Yes, you can do it, and the results can be nice, but by God it
by steve_gh 5y ago
Yes - the description of writing Python as like assembling Ikea furniture is absolutely spot-on. Yes, you can do it, and the results can be nice, but by God it is sometimes such a pain.
The comment showing where groipBy, sortBy etc can be found just shows the problem - they are all in different libraries.That's just plain annoying! And don't get me started on the pain of trying to build an Ordered Dictionary with a default initial value!
- mixmastamyk 5y agoLike defaultdict? All dicts have been ordered since 3.6.
- theelous3 5y agoSmall note: they've been sorted as an implementation detail of cpython since 3.6, but as language spec since 3.7.
- robertlagrant 5y ago> And don't get me started on the pain of trying to build an Ordered Dictionary with a default initial value! >>> from collections import defaultdict >>> from datetime import datetime >>> >>> d = defaultdict(datetime.now) >>> d[1], d[2], d[3], d[4], d[0] (datetime.datetime(2021, 7, 9, 15, 50, 52, 87605), datetime.datetime(2021, 7, 9, 15, 50, 52, 87613), datetime.datetime(2021, 7, 9, 15, 50, 52, 87614), datetime.datetime(2021, 7, 9, 15, 50, 52, 87615), datetime.datetime(2021, 7, 9, 15, 50, 52, 87616)) >>> for k,v in d.items(): ... print(k,v) ... 1 2021-07-09 15:50:52.087605 2 2021-07-09 15:50:52.087613 3 2021-07-09 15:50:52.087614 4 2021-07-09 15:50:52.087615 0 2021-07-09 15:50:52.087616 >>> Seems pretty good to me?