On Sat, 26 Feb 2022 at 10:05, Albert-Jan Roskam <sjeik_ap...@hotmail.com> wrote:
>    Was also thinking about reduce, though this one uses a dunder method:
>    from functools import reduce
>    d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']}
>    print(reduce(list.__add__, list(d.values())))

If you don't want to use the dunder, just use the operator module:

reduce(operator.add, d.values())

But ultimately, that's still the same as sum(), and it's no more
readable than chain(), so I'd still be inclined to go with chain and
then wrap it in a function if you need the clarity.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to