Andrew Koenig wrote:
>>Function arguments are not covered by this trick, but
>>
>>def bar(z):
>>(x,y) = z
>>
>>probably isn't too much overhead...
>
>
> It's not the machine overhead, it's the intellectual overhead. I know there
> are some who will disagree with me, but I would find
Alex Martelli wrote:
> On Mar 7, 2006, at 6:15 AM, Georg Brandl wrote:
>>with expr as f:
>>do something with f
I expect the "with" example here is a red herring,
not intended to have anything to do with the new
"with" statement that's just been added.
> I think the best use cases for 'assign
> Function arguments are not covered by this trick, but
>
> def bar(z):
> (x,y) = z
>
> probably isn't too much overhead...
It's not the machine overhead, it's the intellectual overhead. I know there
are some who will disagree with me, but I would find it easier to read
de
On 3/7/06, Andrew Koenig <[EMAIL PROTECTED]> wrote:
> As it turns out, Python has similar ways of decomposing data structures:
>
> (x, y) = foo
>
> or
>
> def bar((x, y)):
> # etc.
>
> and I have sometimes wished I could write
>
> z as (x, y) = foo
>
> or
>
>
> 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.
ML has a similar feature, which you may
Guido van Rossum wrote:
> On 3/7/06, Georg Brandl <[EMAIL PROTECTED]> 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?
>>
>> Easily.
>>
>> if expr as name:
>> BLOCK
>>
>> would be equivalent to
>>
>> name = exp
Georg Brandl <[EMAIL PROTECTED]> wrote:
> or something like
>
> m = re.match(...)
> if m.group(1) as filename:
> do something with filename
Except that m could be None, which would raise an exception during the
.group(1) call. Perhaps you meant...
m = re.match(...)
if m and m.group(1) as f
Alex Martelli wrote:
> I think the best use cases for 'assignment inside an if or while'
> condition, as far as they go, require `capturing' a SUB-expression of
> the condition, rather than the whole condition. E.g., in C,
>
> while ( (x=next_x()) < threshold ) ...
>
> being able to capture
On 3/7/06, Georg Brandl <[EMAIL PROTECTED]> 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?
>
> Easily.
>
> if expr as name:
> BLOCK
>
> would be equivalent to
>
> name = expr
> if name:
> BLOCK
> del name
[HPH the BDFL]
> I suggest you file those as products of an overactive imagination. :-)
At least not only mine. ;)
> Have you even tried to define precise semantics for any of those, like
> the expansion of "with E as V: B" in PEP 343?
Easily.
if expr as name:
BLOCK
would be equivalent to
On Mar 7, 2006, at 6:15 AM, Georg Brandl wrote:
> Hi,
>
> while "as" is being made a keyword, I remembered parallels between
> "with"
> and a proposal made some time ago:
>
> with expr as f:
> do something with f
>
> while expr as f:
> do something with f
>
> if expr as f:
> do some
I suggest you file those as products of an overactive imagination. :-)
Have you even tried to define precise semantics for any of those, like
the expansion of "with E as V: B" in PEP 343?
--Guido
On 3/7/06, Georg Brandl <[EMAIL PROTECTED]> wrote:
> Hi,
>
> while "as" is being made a keyword, I r
12 matches
Mail list logo