Re: [Python-Dev] Wishlist: dowhile

2005-06-15 Thread Josiah Carlson
Charles Cazabon <[EMAIL PROTECTED]> wrote: > Indeed. The original poster seems to want something that would work (not > necessarily look) like this: > > do: > > while > > with executed once prior to first being tested. But the > above is ugly, and you can get much the same effect

Re: [Python-Dev] Wishlist: dowhile

2005-06-15 Thread Charles Cazabon
Nicolas Fleury <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > Why are you so excited about having until indented? You didn't give > > any examples with multiple occurrences. A single occurrence works just > > fine unindented, as PEP 315 has already shown. > > FWIW, I must say I disagree

Re: [Python-Dev] Wishlist: dowhile

2005-06-15 Thread Nicolas Fleury
Guido van Rossum wrote: > Why are you so excited about having until indented? You didn't give > any examples with multiple occurrences. A single occurrence works just > fine unindented, as PEP 315 has already shown. FWIW, I must say I disagree (about "works just fine"). I find PEP 315 counter-in

Re: [Python-Dev] Wishlist: dowhile

2005-06-15 Thread Andrew Koenig
> > I believe that Algol 68 loops looked like the following (in somewhat > > more Python-like terms): > > > > [for [from ] [step ] to ] > > [while ] > > do od > As far as I remember, it was: > do > > while > > od > It might be that this could be preceded by a 'for'

Re: [Python-Dev] Wishlist: dowhile

2005-06-15 Thread Nick Coghlan
Guido van Rossum wrote: > Why are you so excited about having until indented? You didn't give > any examples with multiple occurrences. A single occurrence works just > fine unindented, as PEP 315 has already shown. I hadn't actually thought about the temptation to try and have multiple 'until' s

Re: [Python-Dev] Wishlist: dowhile

2005-06-14 Thread Eric Nieuwland
Guido van Rossum wrote: > On 6/14/05, Eric Nieuwland <[EMAIL PROTECTED]> wrote: >> From Programming Languages 101 I remember this construct in Algol 68. >> It was then claimed to be *the* universal loop construct. If that is >> true __and__ it is easy to implement, I'd say +INF for PEP 315. > > It

Re: [Python-Dev] Wishlist: dowhile

2005-06-14 Thread Guido van Rossum
On 6/14/05, Eric Nieuwland <[EMAIL PROTECTED]> wrote: > From Programming Languages 101 I remember this construct in Algol 68. > It was then claimed to be *the* universal loop construct. If that is > true __and__ it is easy to implement, I'd say +INF for PEP 315. It's true, but this both dates you

Re: [Python-Dev] Wishlist: dowhile

2005-06-14 Thread Andrew Koenig
> > With PEP 315, a do-while loop would look like: > > > >do: > > > >while : > >pass > > But then, I'm reasonably happy with the 'break out of an infinite > > loop' approach, so *shrug*. > From Programming Languages 101 I remember this construct in Algol 68. > It was then

Re: [Python-Dev] Wishlist: dowhile

2005-06-14 Thread Guido van Rossum
On 6/14/05, BJörn Lindqvist <[EMAIL PROTECTED]> wrote: > Oh. I had the impression that the reason do-while's (or do-until's > which I like more) wasn't implemented in the language was because it > was impossible to find an acceptable looking syntax. No, just because it's fairly redundant. > > >

Re: [Python-Dev] Wishlist: dowhile

2005-06-14 Thread Eric Nieuwland
Nick Coghlan wrote: > With PEP 315, a do-while loop would look like: > >do: > >while : >pass > > But then, I'm reasonably happy with the 'break out of an infinite > loop' approach, so *shrug*. From Programming Languages 101 I remember this construct in Algol 68. It was th

Re: [Python-Dev] Wishlist: dowhile

2005-06-14 Thread BJörn Lindqvist
> > do: > > > > until > > > > Written like this it is not very obvious that the 'unil' is part of > > the do-until suite. I also imagine it to be difficult to parse and it > > breaks the rule that suites end when there is a dedentation. So, IMHO > > using an indented 'until' is the least evil

Re: [Python-Dev] Wishlist: dowhile

2005-06-14 Thread Raymond Hettinger
[Bob] > islice depends on __getitem__. Incorrect. It uses the iterator protocol. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive

Re: [Python-Dev] Wishlist: dowhile

2005-06-14 Thread Bob Ippolito
On Jun 14, 2005, at 2:25 AM, Raymond Hettinger wrote: >> def readby(inp, blocksize=1024): >> while True: >> data = inp.read(blocksize) >> if not data: >> break >> yield data >> >> for data in readby(inp, blocksize): >> . . . >> > > readby() relies

Re: [Python-Dev] Wishlist: dowhile

2005-06-14 Thread Michael Chermside
Jp Calderone writes: > Anything can be a for loop. > > for chunk in iter(lambda: f1.read(CHUNK_SIZE), ''): > f2.write(chunk) Raymond responds: > It would be nice to have this encapsulated in a file method: > > for chunk in f1.iterblocks(CHUNK_SIZE): > f2.write(chunk) What ever

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Raymond Hettinger
> def readby(inp, blocksize=1024): > while True: > data = inp.read(blocksize) > if not data: > break > yield data > > for data in readby(inp, blocksize): > . . . readby() relies on the existence of a read() method for inp. itertools work with gen

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Bob Ippolito
On Jun 14, 2005, at 1:25 AM, Raymond Hettinger wrote: By the way, whatever happened to "and while"? i.e.: while True: data = inp.read(blocksize) and while data: out.write(data) >>> >>> My favourite version of this is >>> >>>

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Raymond Hettinger
> >> By the way, whatever happened to "and while"? i.e.: > >> > >> while True: > >> data = inp.read(blocksize) > >> and while data: > >> out.write(data) > >> > > > > My favourite version of this is > > > >while: > > data = inp.read(blocksize) > >gives data:

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Bob Ippolito
On Jun 13, 2005, at 10:20 PM, Greg Ewing wrote: > Phillip J. Eby wrote: > > >> By the way, whatever happened to "and while"? i.e.: >> >> while True: >> data = inp.read(blocksize) >> and while data: >> out.write(data) >> > > My favourite version of this is > >while

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Greg Ewing
Phillip J. Eby wrote: > By the way, whatever happened to "and while"? i.e.: > > while True: > data = inp.read(blocksize) > and while data: > out.write(data) My favourite version of this is while: data = inp.read(blocksize) gives data: out.write(data)

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Raymond Hettinger
[Jp Calderone] > Anything can be a for loop. > > for chunk in iter(lambda: f1.read(CHUNK_SIZE), ''): > f2.write(chunk) It would be nice to have this encapsulated in a file method: for chunk in f1.iterblocks(CHUNK_SIZE): f2.write(chunk) Raymond __

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Michael Chermside
Jp Calderone writes: > for chunk in iter(lambda: f1.read(CHUNK_SIZE), ''): > f2.write(chunk) Phillip J. Eby responds: > Showoff. ;) > > More seriously, I think your translation makes an excellent argument in > *favor* of having a do/while statement for greater clarity. :) Interesting... I

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Michael Hudson
Michael McLay <[EMAIL PROTECTED]> writes: > I think this would be feature creep. It complicates the language > for a very small gain. While the added syntax would be intuitive, it > only saves a line or two over the existing syntax. FWIW, this is my opinion too (and I've written a bunch of while

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Michael McLay
On Monday 13 June 2005 08:07, Nick Coghlan wrote: > Raymond Hettinger wrote: > > [BJörn Lindqvist] > > > >>I would like to have do-while's like this: > >> > >>do: > >> > >>until > >> > >>But I'm sure that has problems too. > > > > That looks nice to me. > > And this could easily be extende

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Guido van Rossum
On 6/13/05, BJörn Lindqvist <[EMAIL PROTECTED]> wrote: > do: > > until > > Written like this it is not very obvious that the 'unil' is part of > the do-until suite. I also imagine it to be difficult to parse and it > breaks the rule that suites end when there is a dedentation. So, IMHO > usi

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Phillip J. Eby
At 08:14 AM 6/13/2005 -0400, Jp Calderone wrote: >On Mon, 13 Jun 2005 01:25:51 -0400, "Phillip J. Eby" ><[EMAIL PROTECTED]> wrote: > >Block-copying a file with read() has the same pattern (e.g. in shutil), but > >you can't make it a for loop. > >Anything can be a for loop. > > for chunk in iter(

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread BJörn Lindqvist
> > >>do: > > >> > > >>until > > >> > > >>But I'm sure that has problems too. > > > > [Raymond Hettinger] > > > That looks nice to me. > > [Nick Coghlan] > > And this could easily be extended to allow code both before and after > > the 'until', giving a fully general loop: > > > >do:

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Guido van Rossum
> > [BJörn Lindqvist] > > > >>I would like to have do-while's like this: > >> > >>do: > >> > >>until > >> > >>But I'm sure that has problems too. > > [Raymond Hettinger] > > That looks nice to me. [Nick Coghlan] > And this could easily be extended to allow code both before and after > the

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Jp Calderone
On Mon, 13 Jun 2005 01:25:51 -0400, "Phillip J. Eby" <[EMAIL PROTECTED]> wrote: >At 09:01 PM 6/12/2005 -0700, Guido van Rossum wrote: >>If we have to do this, PEP 315 has my +0. >> >>It is Pythonically minimal and the motivation rings true: I've often >>written code like this in the past: >> >>

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Nick Coghlan
Raymond Hettinger wrote: > [BJörn Lindqvist] > >>I would like to have do-while's like this: >> >>do: >> >>until >> >>But I'm sure that has problems too. > > > That looks nice to me. And this could easily be extended to allow code both before and after the 'until', giving a fully gene

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Dmitry Dvoinikov
>> do: >> >> until > That looks nice to me. Except this puts loop entry statement (do) and loop condition test (until) on different levels of indentation, which is I don't quite like. Compared to the existing loop statements, --- while Cond: body else: exit ---

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread Raymond Hettinger
[BJörn Lindqvist] > I would like to have do-while's like this: > > do: > > until > > But I'm sure that has problems too. That looks nice to me. Raymond ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listi

Re: [Python-Dev] Wishlist: dowhile

2005-06-13 Thread BJörn Lindqvist
> In contrast, the dowhile solution only takes about 30 seconds to get > used to. Maybe that idea should follow the path of the genexp PEP, get > rejected now, and then get resurrected as a bright idea two years from > now. Or maybe not. dowhile foo != 42: <10 lines of body> foo = rando

Re: [Python-Dev] Wishlist: dowhile

2005-06-12 Thread Raymond Hettinger
> By the way, whatever happened to "and while"? That is making something hard and weird out of something simple. There were no shortage of odd suggestions to force the condition line to appear lower in the block than the starting line. All of them smelled of rotten eggs -- they just don't fit th

Re: [Python-Dev] Wishlist: dowhile

2005-06-12 Thread Phillip J. Eby
At 09:01 PM 6/12/2005 -0700, Guido van Rossum wrote: >If we have to do this, PEP 315 has my +0. > >It is Pythonically minimal and the motivation rings true: I've often >written code like this in the past: > > line = f.readline() > while line: > > line = f.readline() > >But

Re: [Python-Dev] Wishlist: dowhile

2005-06-12 Thread Josiah Carlson
Nick Coghlan <[EMAIL PROTECTED]> wrote: > > Raymond Hettinger wrote: > > More than case-statement semantics or PEP343, I wish for a dowhile > > statement. > > > > The most straight-forward way is to put the conditional expression at > > the beginning of the block with the understanding that a do

Re: [Python-Dev] Wishlist: dowhile

2005-06-12 Thread Guido van Rossum
On 6/12/05, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Raymond Hettinger wrote: > > More than case-statement semantics or PEP343, I wish for a dowhile > > statement. > > > > The most straight-forward way is to put the conditional expression at > > the beginning of the block with the understanding th

Re: [Python-Dev] Wishlist: dowhile

2005-06-12 Thread Nick Coghlan
Raymond Hettinger wrote: > More than case-statement semantics or PEP343, I wish for a dowhile > statement. > > The most straight-forward way is to put the conditional expression at > the beginning of the block with the understanding that a dowhile keyword > will evaluate the condition only after t