I didn't know this was in, but I'm glad to see it. Professionally I've used 3.6 (which doesn't have this), and with multiple long line context managers and black, it's really hard to format:
If you have this:
with some_really_long_context_manager(), and_something_else_makes_the_line_too_long():
pass
You have to write this which is ugly:
with some_really_long_context_manager(), \
and_something_else_makes_the_line_too_long():
pass
If your arguments are too long:
with some_context(and_long_arguments), and_another(now_the_line_is_too_long):
pass
You can do something like:
with some_context(and_long_arguments), and_another(
now_the_line_is_too_long
):
pass
But that doesn't work if one context manager doesn't take arguments, and it looks slightly odd anyway:
with some_context(and_long_arguments), one_without_arguments(
), and_another(now_the_line_is_too_long):
pass
To do this, you have to rearrange:
with some_context(and_long_arguments), and_another(
now_the_line_is_too_long
), one_without_arguments():
pass
With the new syntax, this can be formatted as:
with (
some_context(and_long_arguments),
one_without_arguments(),
and_another(now_the_line_is_too_long),
):
pass
This also makes diffs more readable.