
On Tue, Mar 01, 2022 at 09:27:05PM -0800, Christopher Barker wrote:
I think it's really the equivalent of
for x in y: if not x in c: break do_stuff
which to me give the proposed syntax a bit more relative strength.
Forgotten the difference between continue and break, have we? :-) Svein (the OP) did specify continue, not break, which matches the equivalent syntax in comprehensions. Semantically, there is no difference between if not condition: continue block and if condition: block but as of CPython 3.10, the byte-code from the first version is slightly longer, so I imagine (but haven't measured) it will be ever-so-slightly less efficient. (But unlikely to be meaningfully different.)
I'm probably +0 -- but I do like comprehension syntax, and have often wanted a "side effect" comprehension:
Me too! I've sometimes wanted something to call a bunch of functions, or a single function with different arguments, solely for the side-effects. Off-topic, but since you raised the issue... is there a standard functional programming term for a variant of map() that applies a single argument to a series of different functions? # regular map map(func, list_of_args) # (func(arg) for arg in list_of_args) # variant map? map(arg, list_of_funcs) # (func(arg) for func in list_of_funcs) -- Steve