[Python-ideas] Object grabbing
MRAB
python at mrabarnett.plus.com
Mon May 2 16:41:52 EDT 2016
On 2016-05-02 14:57, Koos Zevenhoven wrote:
> On Mon, May 2, 2016 at 3:44 PM, Alexander Walters
> <tritium-list at sdamon.com> wrote:
>> with open(foo), open(bar):
>> .write(baz) # does what?
>>
>
> Hopefully it would raise an exception, even though, in the spirit of
> May 1st, it would pick one of the two files at random ;-).
>
This:
with open(foo), open(bar):
.write(baz) # does what?
is basically just a shorter way to write this:
with open(foo):
with open(bar):
.write(baz) # does what?
so that suggests that it would pick the last one.
Anyway, the exception (or warning?) could be raised at compile-time if
the leading-dot form was used in a 'with' that had more than one expression.
More information about the Python-ideas
mailing list