Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-05-02 Thread Luis P Caamano
On 4/29/05, Reinhold Birkenfeld wrote: > Date: Sat, 30 Apr 2005 00:53:12 +0200 > From: Reinhold Birkenfeld <[EMAIL PROTECTED]> > Subject: [Python-Dev] Re: PEP 340 - possible new name for >block-statement > To: python-dev@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/pla

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-05-01 Thread Guido van Rossum
[Phillip] > By the way, I notice PEP 340 has two outstanding items with my name on > them; let me see if I can help eliminate one real quick. > > Tracebacks: it occurs to me that I may have unintentionally given the > impression that I need to pass in an arbitrary traceback, when in fact I > only

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Phillip J. Eby
At 04:02 PM 4/29/05 -0700, Guido van Rossum wrote: Actually, I think this is a nice way to have my cake and eat it too: on the one hand, there still isn't any user-defined syntax, because the keyword-less block syntax is still fixed by the compiler. On the other hand, people are free to *think* of

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Shane Holloway (IEEE)
Guido van Rossum wrote: [Phillip J. Eby] Although I'd personally prefer a no-keyword approach: synchronized(self): with_file("foo") as f: # etc. I'd like that too, but it was shot down at least once. Maybe we can resurrect it? opening("foo") as f: # etc. is just

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Nick Coghlan
Pierre Barbier de Reuille wrote: Mmmmh ... why introduce a new flag ? Can't you just test the presence of the "__error__" method ? This would lift your problem wouldn't it ? Perhaps - it would require doing something a little tricky with generators to allow the programmer to specify whether the g

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Rodrigo B. de Oliveira
On 4/29/05, Guido van Rossum <[EMAIL PROTECTED]> wrote: > [Phillip J. Eby] > > Although I'd personally prefer a no-keyword approach: > > > > synchronized(self): > > with_file("foo") as f: > > # etc. > > I'd like that too, but it was shot down at least once. Maybe we can

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Guido van Rossum
[Phillip] > > In the second place, the most important cue to understanding the behavior > > of a template block is the template function itself; the bare syntax gives > > it the most prominence. Blocks like 'synchronized(self):' should be > > instantly comprehensible to Java programmers, for examp

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Aahz
On Fri, Apr 29, 2005, Phillip J. Eby wrote: > > Actually, I've just realized that I was misled by your argument into > thinking that the possibility of confusing a multi-line call and a block of > this sort is a problem. It's not, because template blocks can be viewed as > multi-line calls that

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Phillip J. Eby
At 12:05 PM 4/29/05 -0700, Aahz wrote: On Fri, Apr 29, 2005, Phillip J. Eby wrote: > At 10:42 AM 4/29/05 -0700, Aahz wrote: >>On Fri, Apr 29, 2005, Guido van Rossum wrote: >>> [Phillip J. Eby] Although I'd personally prefer a no-keyword approach: synchronized(self):

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Aahz
On Fri, Apr 29, 2005, Phillip J. Eby wrote: > At 10:42 AM 4/29/05 -0700, Aahz wrote: >>On Fri, Apr 29, 2005, Guido van Rossum wrote: >>> [Phillip J. Eby] Although I'd personally prefer a no-keyword approach: synchronized(self): with_file("foo") as f:

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Ron Adam
Guido van Rossum wrote: [Ron Adam] How about 'serve' as in a server of items from a service? No, please. This has way too strong connotations with network protocols. Errr... you're right of course... :-/ (I was thinking *way* to narrow.) I think the context is correct, just need a synonym that

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Guido van Rossum
[Ron Adam] > How about 'serve' as in a server of items from a service? No, please. This has way too strong connotations with network protocols. -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@pyth

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Ron Adam
Jim Jewett wrote: Nick Coghlan: Python offers two variants on the basic iterative loop. "for NAME in EXPR:" skips the finalisation step. At loop completion, a well-behaved iterator may still contain additional values. "for NAME from EXPR:" enforces finalisation of the iterator. ... At loop

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Phillip J. Eby
At 10:42 AM 4/29/05 -0700, Aahz wrote: On Fri, Apr 29, 2005, Guido van Rossum wrote: > [Phillip J. Eby] >> >> Although I'd personally prefer a no-keyword approach: >> >> synchronized(self): >> with_file("foo") as f: >> # etc. > > I'd like that too, but it was shot down at

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Aahz
On Fri, Apr 29, 2005, Guido van Rossum wrote: > [Phillip J. Eby] >> >> Although I'd personally prefer a no-keyword approach: >> >> synchronized(self): >> with_file("foo") as f: >> # etc. > > I'd like that too, but it was shot down at least once. Maybe we can > resurrect

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread David Ascher
> I agree, but does this then work: > > x = opening("foo") > ...stuff... > x as f: ># etc > > ? And if not, why not? And if yes, what happens if "stuff" raises an > exception? Forget it -- the above is probably addressed by the PEP and doesn't really depend on whether there's a kw or not.

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread David Ascher
On 4/29/05, Guido van Rossum <[EMAIL PROTECTED]> wrote: > [Phillip J. Eby] > > Although I'd personally prefer a no-keyword approach: > > > > synchronized(self): > > with_file("foo") as f: > > # etc. > > I'd like that too, but it was shot down at least once. Maybe we can

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Guido van Rossum
[Phillip J. Eby] > Although I'd personally prefer a no-keyword approach: > > synchronized(self): > with_file("foo") as f: > # etc. I'd like that too, but it was shot down at least once. Maybe we can resurrect it? opening("foo") as f: # etc. is just a beaut

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Josiah Carlson
Nick Coghlan <[EMAIL PROTECTED]> wrote: > # Non-finalised semantics > arg = None > while True: > try: > VAR1 = next(itr, arg) > except StopIteration: > BLOCK2 > break > arg = None >

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Phillip J. Eby
At 09:38 AM 4/29/05 -0700, Aahz wrote: -1 -- the Zen of Python implies that we should be able to tell which construct we're using at the beginning of the line. Hm, maybe we should just use "@", then. :) e.g. @synchronized(self): @with_file("foo") as f: # etc. Although I'd p

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Josiah Carlson
Nick Coghlan <[EMAIL PROTECTED]> wrote: > Then, in Py3K, finalisation could simply become the default for loop > behaviour. > However, the '__finalise__' flag would result in some impressive code bloat, > as > any for loop would need to expand to: > > itr = iter(EXPR1) > if getattr(

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread David Ascher
On 4/28/05, Guido van Rossum <[EMAIL PROTECTED]> wrote: > How about, instead of trying to emphasize how different a > block-statement is from a for-loop, we emphasize their similarity? > > A regular old loop over a sequence or iterable is written as: > > for VAR in EXPR: > BLOCK > >

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Aahz
On Fri, Apr 29, 2005, Nick Coghlan wrote: > > If you want to emphasise the similarity, the following syntax and > explanation is something that occurred to me during lunch today: We don't want to emphasize the similarity. > Python offers two variants on the basic iterative loop. > > "for NAM

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Pierre Barbier de Reuille
Nick Coghlan a écrit : Pierre Barbier de Reuille wrote: One main reason is a common error could be (using the synchronised iterator introduced in the PEP): for l in synchronised(mylock): do_something() It will compile, run, never raise any error but the lock will be acquired and never released

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Nick Coghlan
Jim Jewett wrote: Why not just agressively run the finalization on both forms when the reference count permits? So the iterator is always finalised if the for loop has the only reference? Two problems I can see there is that naming the target of the for loop would prevent it being finalised, and t

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Nick Coghlan
Pierre Barbier de Reuille wrote: One main reason is a common error could be (using the synchronised iterator introduced in the PEP): for l in synchronised(mylock): do_something() It will compile, run, never raise any error but the lock will be acquired and never released ! It's better than tha

[Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Jim Jewett
Nick Coghlan: > Python offers two variants on the basic iterative loop. >"for NAME in EXPR:" skips the finalisation step. At loop > completion, a well-behaved iterator may still contain additional values. > "for NAME from EXPR:" enforces finalisation of the iterator. > ... At loop complet

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Pierre Barbier de Reuille
Nick Coghlan a écrit : Python offers two variants on the basic iterative loop. "for NAME from EXPR:" enforces finalisation of the iterator. At loop completion, a well-behaved iterator is always completely exhausted. This form supports block management operations, that ensure timely release of

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-29 Thread Nick Coghlan
Guido van Rossum wrote: How about, instead of trying to emphasize how different a block-statement is from a for-loop, we emphasize their similarity? If you want to emphasise the similarity, the following syntax and explanation is something that occurred to me during lunch today: Python offers two

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-28 Thread Guido van Rossum
> Far too close to the "for" loop, IMHO. I read that, I'd have to remind > myself every time, "now, which one is it that can receive values passed > back in: for ... in, or in ... for?" Whoa! Read the PEP closely. Passing a value back to the iterator (using "continue EXPR") is supported both in th

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-28 Thread Robin Munn
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Guido van Rossum wrote: | How about, instead of trying to emphasize how different a | block-statement is from a for-loop, we emphasize their similarity? | | A regular old loop over a sequence or iterable is written as: | | for VAR in EXPR: |

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-28 Thread Greg Ewing
Neil Schemenauer wrote: A variation on this with somewhat different semantics swaps the keywords: in EXPR for VAR: BLOCK Looks weird to my eyes. Probably makes perfect sense if you're Dutch, though. :-) -- Greg Ewing, Computer Science Dept, +--+ Univers

Re: [Python-Dev] PEP 340 - possible new name for block-statement

2005-04-28 Thread Neil Schemenauer
On Thu, Apr 28, 2005 at 03:55:03PM -0700, Guido van Rossum wrote: > A variation on this with somewhat different semantics swaps the keywords: > > in EXPR for VAR: > BLOCK Looks weird to my eyes. On a related note, I was thinking about the extra cleanup 'block' provides. If the 'file

[Python-Dev] PEP 340 - possible new name for block-statement

2005-04-28 Thread Guido van Rossum
How about, instead of trying to emphasize how different a block-statement is from a for-loop, we emphasize their similarity? A regular old loop over a sequence or iterable is written as: for VAR in EXPR: BLOCK A variation on this with somewhat different semantics swaps the keywords: