I wish:
def many(f, n):
return (f() for _ in range(n))
#used like:
v, c, d, b = many(list, 4)
or something very similiar
came with default python. I have to do it for nearly every single project.
I don’t want to define helpers just to express something that is conceptually simple and safe.
chained assignements evaluate each expression once, while tuple unpacking does it seperately and neither are very much fun.
there's no standard syntax for evaluationg expressions (O)N to unpack the results.
I think new syntax would be justified.
and no
v, c, d, b = iter(list, None)
is not acceptable because it breaks for ints, bools, strings and floats.
I would also love something for the leftern side of the equation too but asking for that's a stretch that will likely never be met, even lesso than a default 'many'.