[Python-Dev] "as" mania
g.brandl at gmx.net
Tue Mar 7 19:34:18 CET 2006
Guido van Rossum wrote:
> On 3/7/06, Georg Brandl <g.brandl at gmx.net> wrote:
>> > Have you even tried to define precise semantics for any of those, like
>> > the expansion of "with E as V: B" in PEP 343?
>> if expr as name:
>> would be equivalent to
>> name = expr
>> if name:
>> del name
> You need to be a little more formal. What happens when there are elif
> or else clauses? Why the del at all? (with doesn't delete VAR).
> You also need to present a better motivation. What would be the point
> of having a separate name for the value True or False when you already
> know its value based on which branch you execute? And what exactly is
> the big savings? If you look at the motivation for with E as V, V is
> *not* assigned the value of E (but rather E.__context__().__enter__())
> and the with statement as a whole has a very good reason for its
> existence. Your proposal here lacks that.
Thinking over it, this is too much a difference between the with-"as" and
my "as", so I'm abandoning this idea. My "as" would just have been a shortcut
to avoid writing longish expressions that have to be checked for true-ness and
then tinkered with.
>> Same for while.
> You aren't really trying, are you?
No ;) I would have written a PEP anyway.
More information about the Python-Dev