4 ms·
Yeah i did a multi level nested one once including else clauses, and it didnt actually assign to anything, only side effects. Felt clever at the time. But it w
by TheAdamist 4y ago
Yeah i did a multi level nested one once including else clauses, and it didnt actually assign to anything, only side effects. Felt clever at the time.
But it was completely incomprehensible and unmaintainable. So got replaced by me later.
- Waterluvian 4y agoomg. A comprehension for side effects only. That’s so horrible I wish I could see it. :)
- leetrout 4y agoI worked with a guy that did this. Instead of writing for loops he would write comprehensions everywhere because "list comprehensions are pythonic". Think like: [send_welcome_email(u) for u in users] Just hanging out in the middle of the module or function.
- 83457 4y agoI prefer sent = [(u, send_welcome_email(u)) for u in users]
- Waterluvian 4y agoJust make the function return the argument passed into it. ;)
- Ultimatt 4y agoI prefer not_sent = users - {u for u in users if send_welcome_email(u)}
- 83457 4y agowoah
- BeetleB 4y agoI do it all the time :-) Just make sure it isn't consuming a lot of RAM and it's totally OK.