At 06:56 PM 5/16/2005 +1000, Nick Coghlan wrote:
>Anyway, I think it's stable enough now that I can submit it to be put up on
>www.python.org (I'll notify the PEP editors directly once I fix a couple of
>errors in the current version - like the missing 'raise' in the statement
>semantics. . .).
If
Nick's PEP 3XX is here:
http://members.iinet.net.au/~ncoghlan/public/pep-3XX.html
[Phillip J. Eby]
> Anyway, I took a look at it, and I mostly like it.
I like the beginning of Nick's PEP too, since its spec for the with
statement is now identical to PEP 343 apart from the keyword choice
(and I'm
At 11:20 AM 5/16/2005 -0700, Guido van Rossum wrote:
>I think the issue here is not implementation details but whether it
>follows a certain protocol. IMO it's totally acceptable to require
>that the expression used in a with-statement support an appropriate
>protocol, just like we require the expr
Phillip J. Eby wrote:
> I'm suggesting that we simply take Nick's proposal to its logical
> conclusion, and allow any object to be usable under "with", since it
> does not create any problems to do so. (At least, none that I can
> see.) A redundant 'with' does no harm; in the worst case it's j
[Nick Coghlan (replying to Phillip)]
> Do you mean translating this:
>
>with EXPR1 as VAR1:
>BLOCK1
>
> To something along the lines of:
>
>the_stmt = EXPR1
>stmt_enter = getattr(the_stmt, "__enter__", None)
>stmt_exit = getattr(the_stmt, "__exit__", None)
>
>if stmt
At 11:03 PM 5/17/2005 +1000, Nick Coghlan wrote:
>Do you mean translating this:
>
>with EXPR1 as VAR1:
>BLOCK1
>
>To something along the lines of:
>
>the_stmt = EXPR1
>stmt_enter = getattr(the_stmt, "__enter__", None)
>stmt_exit = getattr(the_stmt, "__exit__", None)
>
>i
At 07:17 AM 5/17/2005 -0700, Guido van Rossum wrote:
>The compiler must generate both code paths but one is wasted.
Not if the default behavior is encapsulated in PyResource_Enter()
(returning the object if no __enter__) and PyResource_Exit() (a no-op if no
__exit__). You're going to have to ha
Nick Coghlan wrote:
>the_stmt = EXPR1
>stmt_enter = getattr(the_stmt, "__enter__", None)
>stmt_exit = getattr(the_stmt, "__exit__", None)
>
>if stmt_enter is None:
>VAR1 = the_stmt
>else:
>VAR1 = stmt_enter()
If we're doing this, it might be better if VAR were
And we're back at PEP 310 and you can't really write opening() as a generator.
On 5/17/05, Greg Ewing <[EMAIL PROTECTED]> wrote:
> Nick Coghlan wrote:
>
> >the_stmt = EXPR1
> >stmt_enter = getattr(the_stmt, "__enter__", None)
> >stmt_exit = getattr(the_stmt, "__exit__", None)
> >
> >
At 12:48 PM 5/18/2005 +1200, Greg Ewing wrote:
>Nick Coghlan wrote:
>
> >the_stmt = EXPR1
> >stmt_enter = getattr(the_stmt, "__enter__", None)
> >stmt_exit = getattr(the_stmt, "__exit__", None)
> >
> >if stmt_enter is None:
> >VAR1 = the_stmt
> >else:
> >VAR1 = s
[I apologize in advance if this sounds a bit disjointed... I started
to argue one thing, but by the end had convinced myself of the
opposite, and I re-wrote the email to match my final conclusion.]
Guido writes:
> About deleting VAR I have mixed feelings. [...]
> I think that, given that we let th
Guido writes:
[a rather silly objection to Phillip's proposal that 'with x:' is
a no-op when x lacks __enter__ and __exit__]
> I know this is not a very strong argument, but my gut tells me this
> generalization of the with-statement is wrong, so I'll stick to it
> regardless of the strength
Michael Chermside wrote:
> If I write
>
> with foo:
>BLOCK
>
> where I should have written
>
> with locked(foo):
>BLOCK
>
> ...it silently "succeeds" by doing nothing. I CLEARLY intended to
> do the appropriate cleanup (or locking, or whatever), but it doesn't
> happen.
13 matches
Mail list logo