What is Nostr?
Julien Palard /
npub14za…s7uz
2023-12-18 21:29:12
in reply to nevent1q…ty73

Julien Palard on Nostr: npub1kg5kt…vtnac npub1kpwlx…xxzz4 In Python they are functions, not methods, ...

npub1kg5ktxlealkymv59ghper5klmc8n5vqppclxytkqg9jzk0wkmwhqzvtnac (npub1kg5…tnac) npub1kpwlxpzkxfmuxjmzc2wp3rf9vjg0sgydmlhsnrgqr3maf59h86qqdxxzz4 (npub1kpw…xzz4) In Python they are functions, not methods, because they work with any iterable (strings, lists, tuples, bytes, literraly any containers, even the ones you create). It's easier than having to implement a map and a reduce method on every container.

But in Python we don't even use map and filter, comprehensions are (very often) more readable:

>>> sum(map(abs, filter(lambda x: x > 10, the_iterable)))

vs

>>> sum(abs(x) for x in the_iterable if x > 10)
Author Public Key
npub14zawa8lf3lw9swf49a74vjktumq033uar2akhxtl59jtjes6jxdseus7uz