Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-18 Thread Michael Hudson
Nick Coghlan <[EMAIL PROTECTED]> writes: > Ron Adam wrote: >> 3. The "with" documentation could possibly be grouped with or after >> the "try" documentation as it may be easier to understand in that context. > > I was looking for an appropriate place in the tutorial to put a couple of > usa

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-15 Thread Stephen J. Turnbull
> "Jim" == Jim Jewett <[EMAIL PROTECTED]> writes: Jim> Nick Coghlan asked Marc-Andre Lemburg: >> There's clearly something that bothers you about this though, >> and I'd like to understand what it is. Does the term 'context' >> carry additional, more specific, connotations for

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-15 Thread Nick Coghlan
Ron Adam wrote: > 3. The "with" documentation could possibly be grouped with or after > the "try" documentation as it may be easier to understand in that context. I was looking for an appropriate place in the tutorial to put a couple of usage examples - a new subsection immediately after th

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-15 Thread Ron Adam
Guido van Rossum wrote: > On 7/15/05, Ron Adam <[EMAIL PROTECTED]> wrote: > [several new syntax proposals] > > Please stop proposing new syntax. The PEP was accepted after quite > enough back-and-forth; there's no point opening this up yet again. My apologies Guido. Subtracting the inappropriat

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-15 Thread Guido van Rossum
On 7/15/05, Ron Adam <[EMAIL PROTECTED]> wrote: [several new syntax proposals] Please stop proposing new syntax. The PEP was accepted after quite enough back-and-forth; there's no point opening this up yet again. -- --Guido van Rossum (home page: http://www.python.org/~guido/) __

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-15 Thread Ron Adam
Michael Hudson wrote: > "M.-A. Lemburg" <[EMAIL PROTECTED]> writes: > > >>This is exactly what I'm getting at: I can see the potential >>use for resource management (which is what started out the >>whole idea IIRC), but fail to see why you'd want to use it >>for anything more complicated than tha

[Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-15 Thread Jim Jewett
Nick Coghlan asked Marc-Andre Lemburg: > There's clearly something that bothers you about this though, and I'd like to > understand what it is. Does the term 'context' carry additional, more > specific, connotations for you that I'm simply not taking into account? To me, a context is much large

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-15 Thread Nick Coghlan
M.-A. Lemburg wrote: > If you then start using terms in the documentation that cause > wrong associations, you make life harder for new programmers. I agree that every new construct and protocol makes life that much harder for anyone learning Python, but the bit I'm having trouble grasping is why

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-15 Thread Nick Coghlan
M.-A. Lemburg wrote: > This is exactly what I'm getting at: I can see the potential > use for resource management (which is what started out the > whole idea IIRC), but fail to see why you'd want to use it > for anything more complicated than that. The other suggested uses (redirecting stdout, log

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-15 Thread M.-A. Lemburg
Raymond Hettinger wrote: > {MAL] > >>This is exactly what I'm getting at: I can see the potential >>use for resource management (which is what started out the >>whole idea IIRC), but fail to see why you'd want to use it >>for anything more complicated than that. > > > Substitute "different" for

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-15 Thread Michael Hudson
"M.-A. Lemburg" <[EMAIL PROTECTED]> writes: > This is exactly what I'm getting at: I can see the potential > use for resource management (which is what started out the > whole idea IIRC), but fail to see why you'd want to use it > for anything more complicated than that. I, as a concrete example,

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-14 Thread Raymond Hettinger
{MAL] > This is exactly what I'm getting at: I can see the potential > use for resource management (which is what started out the > whole idea IIRC), but fail to see why you'd want to use it > for anything more complicated than that. Substitute "different" for "complicated". 'with' is not applica

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-14 Thread M.-A. Lemburg
Nick Coghlan wrote: > M.-A. Lemburg wrote: > >>May I suggest that you use a different name than "context" for >>this ?! >> >>The term "context" is way to broad for the application scopes >>that you have in mind here (like e.g. managing a resource >>in a multi-threaded application). > > > It's ac

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-08 Thread Nick Coghlan
Terry Reedy wrote: > Would this also work as a decorated generator? > (If I have understood correctly, something like..) > > @contextmanager > def tag(name) >print "<%s>" % name >yield None >print "" % name > > If so, I suggest putting in both versions to make the correspo

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-08 Thread Nick Coghlan
M.-A. Lemburg wrote: > May I suggest that you use a different name than "context" for > this ?! > > The term "context" is way to broad for the application scopes > that you have in mind here (like e.g. managing a resource > in a multi-threaded application). It's actually the broadness of the term

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-08 Thread M.-A. Lemburg
Nick Coghlan wrote: > OK, here's some draft documentation using Phillip's context > terminology. I think it works very well. > > """ > With Statements and Context Management > > A frequent need in programming is to ensure a particular action is > taken after a specific section of code has been e

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-08 Thread Terry Reedy
"Nick Coghlan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Phillip J. Eby wrote: >> I suggest changing this to something like this: >> >> class tag(object): >> def __init__(self,name): >> self.name = name >> def __enter__(self): >> pri

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-08 Thread Terry Reedy
"Walter Dörwald" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >x = blist() >x(1) >with blist(x) as x: >x(2) >with blist(x) as x: > x(3) >x(4) >x(5) >This would create the list: >[1, [2, [3], 4], 5] >With the current version of PEP 343, we would either have to us

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-08 Thread Nick Coghlan
Phillip J. Eby wrote: > I suggest changing this to something like this: > > class tag(object): > def __init__(self,name): > self.name = name > def __enter__(self): > print "<%s>" % name > def __exit__(self): > print "" % name > >

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-08 Thread Michael Hudson
Walter Dörwald <[EMAIL PROTECTED]> writes: > Michael Hudson wrote: > >> Walter Dörwald <[EMAIL PROTECTED]> writes: >> [...] >>>I.e. will VAR still exist after the end of the block with its value >>>the return value of __enter__() or will it revert to the previous >>>value (if any)? >> >> Eh, no.

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-08 Thread Walter Dörwald
Michael Hudson wrote: > Walter Dörwald <[EMAIL PROTECTED]> writes: > [...] >>I.e. will VAR still exist after the end of the block with its value >>the return value of __enter__() or will it revert to the previous >>value (if any)? > > Eh, no. Where would you store the old value? I don't know, w

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-08 Thread Michael Hudson
Walter Dörwald <[EMAIL PROTECTED]> writes: > Am 07.07.2005 um 20:00 schrieb Guido van Rossum: > +1 on @contextmanager >> >> +1. >> >> [__enter__, __exit__] >> > These names should be changed to __beginwith__ and __endwith__. > >> >> -1. The PEP has had an extensive review period and

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-08 Thread Walter Dörwald
Guido van Rossum wrote: > On 7/7/05, Walter Dörwald <[EMAIL PROTECTED]> wrote: > >>What is still unspecified (or at least not explicitely mentioned) in >>the PEP is the lifetime of VAR in: >> >> with EXPR as VAR: >> BLOCK > > It is specified well enough IMO -- you're supposed

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-08 Thread Guido van Rossum
On 7/7/05, Walter Dörwald <[EMAIL PROTECTED]> wrote: > What is still unspecified (or at least not explicitely mentioned) in > the PEP is the lifetime of VAR in: > > with EXPR as VAR: > BLOCK It is specified well enough IMO -- you're supposed to take the translation into basi

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-07 Thread Walter Dörwald
Am 07.07.2005 um 20:00 schrieb Guido van Rossum: >>> +1 on @contextmanager > > +1. > > [__enter__, __exit__] > These names should be changed to __beginwith__ and __endwith__. > > -1. The PEP has had an extensive review period and several > alternatives were discussed and rejected. Thes

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-07 Thread Phillip J. Eby
At 09:12 PM 7/6/2005 +1000, Nick Coghlan wrote: >Another example is the use of contexts to handle insertion of the >appropriate tags when generating HTML: > > with html: >with body: > with h1: > print "Some heading" > with p: > print "This i

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-07 Thread Guido van Rossum
> > +1 on @contextmanager +1. [__enter__, __exit__] > >> These names should be changed to __beginwith__ and __endwith__. -1. The PEP has had an extensive review period and several alternatives were discussed and rejected. These names are clear, they *do* match, and as Fred says the __*__ namesp

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-07 Thread Michael Hudson
Barry Warsaw <[EMAIL PROTECTED]> writes: > +1 on @contextmanager > > On Wed, 2005-07-06 at 19:47, Raymond Hettinger wrote: > >> > __enter__(self): >> > __exit__(self, exc_type, exc_value, exc_traceback): >> >> These names should be changed to __beginwith__ and __endwith__. -1. > -0.

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-06 Thread Barry Warsaw
+1 on @contextmanager On Wed, 2005-07-06 at 19:47, Raymond Hettinger wrote: > > __enter__(self): > > __exit__(self, exc_type, exc_value, exc_traceback): > > These names should be changed to __beginwith__ and __endwith__. -0. My fingers are too hardwired to writing "endswith", as in

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-06 Thread Nicolas Fleury
Fred L. Drake, Jr. wrote: > On Wednesday 06 July 2005 19:47, Raymond Hettinger wrote: > > These names should be changed to __beginwith__ and __endwith__. The > > current names are too vague, not obviously paired with each other, not > > obviously tied to the with-statement, and provide no hint

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-06 Thread Fred L. Drake, Jr.
On Wednesday 06 July 2005 19:47, Raymond Hettinger wrote: > These names should be changed to __beginwith__ and __endwith__. The > current names are too vague, not obviously paired with each other, not > obviously tied to the with-statement, and provide no hint about what > calls them. Remembe

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-06 Thread Raymond Hettinger
[Nick Coghlan] > OK, here's some draft documentation using Phillip's context > terminology. I think it works very well. > > """ > With Statements and Context Management > > A frequent need in programming is to ensure a particular action is > taken after a specific section of code has been execute

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-06 Thread Delaney, Timothy (Tim)
Well, I'm convinced. My votes go to "context management protocol" and @contextmanager. Simple, descriptive and specific in meaning yet wide enough to cover pretty much all the cases we care about. I think we should state in the docs that the most common usage is to set up a specific context and re

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-06 Thread Reinhold Birkenfeld
Paul Moore wrote: > On 7/6/05, Michael Chermside <[EMAIL PROTECTED]> wrote: >> Paul Moore writes: >> > I also like the fact that it offers a neat 1-word name for the >> > generator decorator, "@context". >> >> Well, ok... does anyone *else* agree? I too saw this and thought "neat! >> a simple one-

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-06 Thread Paul Moore
On 7/6/05, Michael Chermside <[EMAIL PROTECTED]> wrote: > Paul Moore writes: > > I also like the fact that it offers a neat 1-word name for the > > generator decorator, "@context". > > Well, ok... does anyone *else* agree? I too saw this and thought "neat! > a simple one-word name!". But then I st

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-06 Thread Nick Coghlan
Paul Moore wrote: > On 7/6/05, Nick Coghlan <[EMAIL PROTECTED]> wrote: > >>OK, here's some draft documentation using Phillip's context >>terminology. I think it works very well. > > > I agree. +1 on this terminology, and for this explanation to be > included in the docs. > > I also like the fac

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-06 Thread Michael Chermside
Nick writes sample documentation: > For example, the following context manager allows prompt closure of > any resource with a 'close' method (e.g. a generator or file): > > @context > def closing(resource): > try: > yield resource > finally: > r

Re: [Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-06 Thread Paul Moore
On 7/6/05, Nick Coghlan <[EMAIL PROTECTED]> wrote: > OK, here's some draft documentation using Phillip's context > terminology. I think it works very well. I agree. +1 on this terminology, and for this explanation to be included in the docs. I also like the fact that it offers a neat 1-word name

[Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

2005-07-06 Thread Nick Coghlan
OK, here's some draft documentation using Phillip's context terminology. I think it works very well. """ With Statements and Context Management A frequent need in programming is to ensure a particular action is taken after a specific section of code has been executed (such as closing a file or