News for hackers. Stuff that matters.
Re:Functools – The Power of Higher-Order Functions in Python by steve_gh on Friday July 09, 2021 @03:32AM (#27781309)
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!

Re:Functools – The Power of Higher-Order Functions in Python by robertlagrant on Friday July 09, 2021 @10:52AM (#27784288)
> 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?
Re:Functools – The Power of Higher-Order Functions in Python by mixmastamyk on Friday July 09, 2021 @03:44AM (#27781364)
Like defaultdict? All dicts have been ordered since 3.6.
Re:Functools – The Power of Higher-Order Functions in Python by theelous3 on Friday July 09, 2021 @04:21AM (#27781542)
Small note: they've been sorted as an implementation detail of cpython since 3.6, but as language spec since 3.7.