News for hackers. Stuff that matters.
Re:Introducing PyScript (summary of PyCon keynote) by js2 on Thursday June 23, 2022 @10:28AM (#31849570)
Use intermediate steps:

    keyOf = itemgetter("myKey")
    valueOf = itemgetter("myValue")
    filtered = (item for item in myList if valueOf(item) > 5)
    grouped = groupby(sorted(filtered, key=keyOf), keyOf)
    result = {key: sum(valueOf(item) for item in group) for key, group in grouped}
Re:Introducing PyScript (summary of PyCon keynote) by musicale on Thursday June 23, 2022 @01:21PM (#31852285)
Could you save a line by replacing valueOf(item) with item.value?
Re:Introducing PyScript (summary of PyCon keynote) by js2 on Thursday June 23, 2022 @01:52PM (#31852745)
OP wrote the code as if the list items were dictionaries, so I just made that pythonic. If they are objects whose attributes we care about then we can get rid of the two getters altogether which are mostly there to make the code more legible but also remove duplication. You could also switch them to attrgetters.
Re:Introducing PyScript (summary of PyCon keynote) by gigatexal on Thursday June 23, 2022 @10:35AM (#31849678)
Ooh I like this. That’s about what I would do as well.