Re: The rap against while True: loops

2009-10-14 Thread Rhodri James
On Wed, 14 Oct 2009 02:26:17 +0100, Mensanator mensana...@aol.com wrote: On Oct 13, 5:38�pm, Rhodri James rho...@wildebst.demon.co.uk wrote: On Tue, 13 Oct 2009 22:59:04 +0100, Mensanator mensana...@aol.com wrote: And I'm not saying John nor the OP should stop using what works for them.

Re: The rap against while True: loops

2009-10-14 Thread Steven D'Aprano
On Wed, 14 Oct 2009 09:34:28 -0700, Mensanator wrote: On Oct 14, 2:19�am, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Tue, 13 Oct 2009 15:02:09 -0700 (PDT), Mensanator mensana...@aol.com declaimed the following in gmane.comp.python.general: You're not getting away that easy.

Re: The rap against while True: loops

2009-10-14 Thread Steven D'Aprano
On Wed, 14 Oct 2009 18:30:06 +0100, Tim Rowe wrote: 2009/10/14 Dennis Lee Bieber wlfr...@ix.netcom.com:        If anything -- I'd suggest a proposal to add a plain    loop           as a keyword in Python, whose effect is equivalent to a while True, but a break    must be used to exit said

Re: The rap against while True: loops

2009-10-14 Thread Steven D'Aprano
On Wed, 14 Oct 2009 20:17:40 +, Jorgen Grahn wrote: But we have exceptions. And I know somebody, in other languages, thinks it's a Best Practice to avoid using exceptions for flow control. A lot of C++ programmers think so, and Stroustrup himself says exceptions are for exceptional

Re: The rap against while True: loops

2009-10-14 Thread Paul Rubin
to make sure that the verification logic is consistent and that type-level inferences are valid. They generally have very little to do with making sure that the program's actual running time is bounded by anything reasonable. In fact infinite loops are permitted in some such systems, but only

Re: The rap against while True: loops

2009-10-14 Thread Mensanator
On Oct 14, 6:08�pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Wed, 14 Oct 2009 09:34:28 -0700, Mensanator wrote: On Oct 14, 2:19 am, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Tue, 13 Oct 2009 15:02:09 -0700 (PDT), Mensanator mensana...@aol.com declaimed the

Re: The rap against while True: loops

2009-10-14 Thread Mensanator
something, but of those, this is the best way, barring special circumstances. For what it's worth, most of my loops run to completion, with no sign of a break anywhere. �Some have a break, and use it. �Some, even, (dare I say it?) use break *and* else! � Breaks can be used properly, but it's

Re: The rap against while True: loops

2009-10-13 Thread John Reid
like while not done_with_this while not done_with_that This is neither clean or well scoped. Besides, since I _always_ initialize the flag before entering a loop, the flag can be reused and doesn't have to be deleted (as long as the loops aren't nested). And since I don't use goto

Re: The rap against while True: loops

2009-10-13 Thread Grant Edwards
On 2009-10-12, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: my_prissy_little_indicator_variable = true while (my_prissy_little_indicator_variable){ body } isn't satisfying because it doesn't guard the body with any assurance that the loop invariant will be true before you enter into

Re: The rap against while True: loops

2009-10-13 Thread Mensanator
not done_with_that This is neither clean or well scoped. Besides, since I _always_ initialize the flag before entering a loop, the flag can be reused and doesn't have to be deleted (as long as the loops aren't nested). And since I don't use goto, there's no chance the initialization can

Re: The rap against while True: loops

2009-10-13 Thread John Reid
Mensanator wrote: No, it's just that the OP was asking whether avoiding while True is considered Best Practice. How can you answer such a question without sounding dogmatic? I was just pointing out your style of programming seems inflexible. Just another line that has to be interpreted

Re: The rap against while True: loops

2009-10-13 Thread Ethan Furman
. If I need more than one loop structure then I'll do something like � � while not done_with_this � � while not done_with_that Besides, since I _always_ initialize the flag before entering a loop, the flag can be reused and doesn't have to be deleted (as long as the loops aren't nested). And since I

Re: The rap against while True: loops

2009-10-13 Thread Mensanator
have to be deleted (as long as the loops aren't nested). And since I don't use goto, there's no chance the initialization can be avoided. Initialising the flag is just another line of code that has to be interpreted later. I didn't notice the initialisation in your original post. Just another

Re: The rap against while True: loops

2009-10-13 Thread Mensanator
On Oct 12, 4:59�pm, David C Ullrich ullr...@math.okstate.edu wrote: kj wrote: I'm coaching a group of biologists on basic Python scripting. �One of my charges mentioned that he had come across the advice never to use loops beginning with while True. �Of course, that's one way to start

Re: The rap against while True: loops

2009-10-13 Thread greg
Steven D'Aprano wrote: The best I have seen is that loops should have a single entry point and a single exit point, to make it easier to reason about pre- and post-conditions. But frankly I'm not convinced that's true -- or at least, multiple exists shouldn't *necessarily* leader

Re: The rap against while True: loops

2009-10-13 Thread Mensanator
On Oct 13, 5:38�pm, Rhodri James rho...@wildebst.demon.co.uk wrote: On Tue, 13 Oct 2009 22:59:04 +0100, Mensanator mensana...@aol.com wrote: And I'm not saying John nor the OP should stop using what works for them. But there are certainly valid reasons for don't use while True to be on

Re: The rap against while True: loops

2009-10-12 Thread greg
Steven D'Aprano wrote: Back in ancient days when dinosaurs walked the Earth, and I was programming in THINK Pascal on Apple Macintosh System 6, I'd go into nervous palpitations writing the equivalent of while True because if I got it wrong, I'd lock up the machine and need to hit the power

Re: The rap against while True: loops

2009-10-12 Thread greg
kj wrote: I'm coaching a group of biologists on basic Python scripting. One of my charges mentioned that he had come across the advice never to use loops beginning with while True. It's possible this is something he was told in relation to another language that has more options. For example

Re: The rap against while True: loops

2009-10-12 Thread Luis Zarrabeitia
On Sunday 11 October 2009 11:56:55 pm Dennis Lee Bieber wrote: In this situation, the middle exit works best -- using non-optimal Python while True: lin = file_object.readline() if not lin: break do something with lin Actually, in

Re: The rap against while True: loops

2009-10-12 Thread Xavier Ho
On Mon, Oct 12, 2009 at 11:32 PM, Luis Zarrabeitia ky...@uh.cu wrote: Actually, in python, this works even better: for lin in iter(file_object.readline, ): ... do something with lin What about with open(path_string) as f: for line in f: # do something Cheers, Xav --

Re: The rap against while True: loops

2009-10-12 Thread Mel
Luis Zarrabeitia wrote: On Sunday 11 October 2009 11:56:55 pm Dennis Lee Bieber wrote: In this situation, the middle exit works best -- using non-optimal Python while True: lin = file_object.readline() if not lin: break do something with lin Actually, in python, this works even better:

Re: The rap against while True: loops

2009-10-12 Thread Luis Zarrabeitia
On Monday 12 October 2009 09:47:23 am Xavier Ho wrote: On Mon, Oct 12, 2009 at 11:32 PM, Luis Zarrabeitia ky...@uh.cu wrote: Actually, in python, this works even better: for lin in iter(file_object.readline, ): ... do something with lin What about with open(path_string) as f:

Re: The rap against while True: loops

2009-10-12 Thread Mensanator
On Oct 12, 3:36�am, greg g...@cosc.canterbury.ac.nz wrote: Mensanator wrote: while not done: � � ... � � if n==1: done = True � � ... Seems to me that 'while not done:' is no better than 'while True:', because in both cases you have to look inside the loop to find out what the exit

Re: The rap against while True: loops

2009-10-12 Thread John Reid
Mensanator wrote: On Oct 12, 3:36�am, greg g...@cosc.canterbury.ac.nz wrote: Mensanator wrote: while not done: � � ... � � if n==1: done = True � � ... Seems to me that 'while not done:' is no better than 'while True:', because in both cases you have to look inside the loop to find out what

Re: The rap against while True: loops

2009-10-12 Thread Ethan Furman
Mensanator wrote: On Oct 12, 3:36�am, greg g...@cosc.canterbury.ac.nz wrote: Mensanator wrote: while not done: � � ... � � if n==1: done = True � � ... Seems to me that 'while not done:' is no better than 'while True:', because in both cases you have to look inside the loop to find out

Re: The rap against while True: loops

2009-10-12 Thread Mensanator
to be deleted (as long as the loops aren't nested). And since I don't use goto, there's no chance the initialization can be avoided. The best way to avoid the pitfalls of spaghetti code is to not write it in the first place. -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against while True: loops

2009-10-12 Thread Falcolas
initialize the flag before entering a loop, the flag can be reused and doesn't have to be deleted (as long as the loops aren't nested). And since I don't use goto, there's no chance the initialization can be avoided. The best way to avoid the pitfalls of spaghetti code is to not write

Re: The rap against while True: loops

2009-10-12 Thread Mensanator
like     while not done_with_this     while not done_with_that Besides, since I _always_ initialize the flag before entering a loop, the flag can be reused and doesn't have to be deleted (as long as the loops aren't nested). And since I don't use goto, there's no chance

Re: The rap against while True: loops

2009-10-12 Thread Raymond Hettinger
[kj] I use while True-loops often, and intend to continue doing this while True, but I'm curious to know: how widespread is the injunction against such loops?  Has it reached the status of best practice? This is the first I've ever heard of such an quasi-injunction. Like you, I use while True

Re: The rap against while True: loops

2009-10-12 Thread Paul Rubin
kj no.em...@please.post writes: I use while True-loops often, and intend to continue doing this while True, but I'm curious to know: how widespread is the injunction against such loops? Has it reached the status of best practice? E. W. Dijkstra used to advocate that every loop have exactly

Re: The rap against while True: loops

2009-10-12 Thread Steven D'Aprano
of complication in loops. There's no need to force every loop to have a single exit point (or for that matter, for every function to have a single return). Compare the straightforward implementation of a simple linear search: for item in seq: if cond(item): print item break versus doing

Re: The rap against while True: loops

2009-10-11 Thread Hendrik van Rooyen
On Saturday, 10 October 2009 22:15:21 kj wrote: I'm coaching a group of biologists on basic Python scripting. One of my charges mentioned that he had come across the advice never to use loops beginning with while True. Of course, that's one way to start an infinite loop, but this seems

Re: The rap against while True: loops

2009-10-11 Thread Steven D'Aprano
On Sat, 10 Oct 2009 20:15:21 +, kj wrote: I use while True-loops often, and intend to continue doing this while True, but I'm curious to know: how widespread is the injunction against such loops? Has it reached the status of best practice? Such an injunction probably made more sense back

Re: The rap against while True: loops

2009-10-11 Thread Grant Edwards
On 2009-10-11, Hendrik van Rooyen hend...@microcorp.co.za wrote: It is often necessary, in long running applications, to set up loops that you would really like to run until the end of time. - the equivalent of a serve forever construct. Then while True is the obvious way to spell it. Once

Re: The rap against while True: loops

2009-10-11 Thread Gabriel Genellina
En Sat, 10 Oct 2009 19:32:25 -0300, Björn Lindqvist bjou...@gmail.com escribió: I have many times screwed up while True-loops. When I thought I had a safe exit condition which turned out to be never reached in some rare corner cases. Leading to weird bugs with hanging threads. I have seen

Re: The rap against while True: loops

2009-10-11 Thread bartc
Mensanator wrote: On Oct 10, 3:15�pm, kj no.em...@please.post wrote: I'm coaching a group of biologists on basic Python scripting. �One of my charges mentioned that he had come across the advice never to use loops beginning with while True. �Of course, that's one way to start an infinite loop

Re: The rap against while True: loops

2009-10-11 Thread Mensanator
On Oct 11, 4:51�pm, bartc ba...@freeuk.com wrote: Mensanator wrote: On Oct 10, 3:15 pm, kj no.em...@please.post wrote: I'm coaching a group of biologists on basic Python scripting. One of my charges mentioned that he had come across the advice never to use loops beginning with while True

Re: The rap against while True: loops

2009-10-11 Thread Philip Semanchuk
On Oct 11, 2009, at 5:51 PM, bartc wrote: Mensanator wrote: On Oct 10, 3:15�pm, kj no.em...@please.post wrote: I'm coaching a group of biologists on basic Python scripting. �One of my charges mentioned that he had come across the advice never to use loops beginning with while True

Re: The rap against while True: loops

2009-10-11 Thread RDrewD
across the advice never to use loops beginning with while True. Of course, that's one way to start an infinite loop, but this seems hardly a sufficient reason to avoid the construct altogether, as long as one includes an exit that is always reached. (Actually, come to think

Re: The rap against while True: loops

2009-10-11 Thread Gabriel Genellina
that he had come across the advice never to use loops beginning with while True.[...] If you know this exit that is always reached, why do you pretend not to know it by writing while True? When I'm starting to code something I haven't yet fully worked out, it often starts with an infinite loop

Re: The rap against while True: loops

2009-10-11 Thread Gabriel Genellina
Python scripting. One of my charges mentioned that he had come across the advice never to use loops beginning with while True. Of course, that's one way to start an infinite loop, but this seems hardly a sufficient reason to avoid the construct altogether, as long as one includes an exit

The rap against while True: loops

2009-10-10 Thread kj
I'm coaching a group of biologists on basic Python scripting. One of my charges mentioned that he had come across the advice never to use loops beginning with while True. Of course, that's one way to start an infinite loop, but this seems hardly a sufficient reason to avoid the construct

Re: The rap against while True: loops

2009-10-10 Thread Stephen Hansen
I use while True-loops often, and intend to continue doing this while True, but I'm curious to know: how widespread is the injunction against such loops? The injunction is nonexistent (save perhaps in people coming from another language who insist that Python just /must/ have a proper do

Re: The rap against while True: loops

2009-10-10 Thread Boris Arloff
I agree there is no rap against while True-loops.  As an example these are very useful especially when receiving continuous data over a queue, pipe socket, or over any other connection.  You set to block, receive data, then process data and finally loop around to wait for next data segment

Re: The rap against while True: loops

2009-10-10 Thread Mensanator
On Oct 10, 3:15�pm, kj no.em...@please.post wrote: I'm coaching a group of biologists on basic Python scripting. �One of my charges mentioned that he had come across the advice never to use loops beginning with while True. �Of course, that's one way to start an infinite loop, but this seems

Re: The rap against while True: loops

2009-10-10 Thread kj
the advice never to use loops beginning with while True. =EF=BF=BDOf course, that's one way to start an infinite loop, but this seems hardly a sufficient reason to avoid the construct altogether, as long as one includes an exit that is always reached. =EF=BF=BD(Actually, come to think

Re: The rap against while True: loops

2009-10-10 Thread Björn Lindqvist
I have many times screwed up while True-loops. When I thought I had a safe exit condition which turned out to be never reached in some rare corner cases. Leading to weird bugs with hanging threads. I have seen colleges screw up in the same way too. Often it is possible to reformulate while True

Re: The rap against while True: loops

2009-10-10 Thread Mensanator
=BDOn= e of my charges mentioned that he had come across the advice never to use loops beginning with while True. =EF=BF=BDOf course, that's one way to start an infinite loop, but this seems hardly a sufficient reason to avoid the construct altogether, as long as one includes an exit

Re: The rap against while True: loops

2009-10-10 Thread Peter Billam
On 2009-10-10, kj no.em...@please.post wrote: I use while True-loops often, and intend to continue doing this while True, but I'm curious to know: how widespread is the injunction against such loops? Has it reached the status of best practice? This trend is ironic; I remember

Re: The rap against while True: loops

2009-10-10 Thread Terry Reedy
kj wrote: I use while True-loops often, and intend to continue doing this while True, Me too. Of course, in Python, 'while True' actually means 'while ^C not pressed and window not closed and process not killed:', whereas in old mainframe Fortran the equivalent might have meant 'while my

How to jump out of nested 'for'-loops?

2009-09-28 Thread Peng Yu
Hi, I want some command to jump out of nested loop. I'm wondering what is the most convenient way to do so in python. for i in range(10): print i = , i for j in range(10): if i*10 + j == 50: print i*10 + j break # I want to jump out of the loops. Regards, Peng -- http

Re: How to jump out of nested 'for'-loops?

2009-09-28 Thread Zero Piraeus
: I want some command to jump out of nested loop. I'm wondering what is the most convenient way to do so in python. http://www.google.com/search?q=python+nested+break -[]z. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to jump out of nested 'for'-loops?

2009-09-28 Thread r
# I want to jump out of the loops. Regards, Peng if your code is in a function/method just use return -- http://mail.python.org/mailman/listinfo/python-list

Re: How to jump out of nested 'for'-loops?

2009-09-28 Thread Sean DiZazzo
# I want to jump out of the loops. Regards, Peng Can you please give the people who answered your question a simple thank you?? ~Sean -- http://mail.python.org/mailman/listinfo/python-list

Re: How to jump out of nested 'for'-loops?

2009-09-28 Thread D'Arcy J.M. Cain
. for i in range(10): print i = , i for j in range(10): if i*10 + j == 50: print i*10 + j break # I want to jump out of the loops. def myfunc(li, lim, mul): for i in li: print i = , i for j in range(10): if i*mul + j == lim: return i*mul + j print

Re: How to jump out of nested 'for'-loops?

2009-09-28 Thread alex23
Peng Yu pengyu...@gmail.com wrote: I want some command to jump out of nested loop. I'm wondering what is the most convenient way to do so in python. I'm sure I'm wasting my breath by saying this, but would it hurt you to actually check the list before posting? You're not the only person to ever

Re: flow control and nested loops

2009-09-26 Thread Raymond Hettinger
On Sep 25, 12:01 pm, kj no.em...@please.post wrote: In Perl, one can label loops for finer flow control.  For example: X: for my $x (@X) {   Y: for my $y (@Y) {     for my $z (@Z) {       next X if test1($x, $y, $z);       next Y if test2($x, $y, $z);       frobnicate($x, $y, $z

Re: flow control and nested loops

2009-09-26 Thread Bearophile
Raymond Hettinger: Another approach for exiting multiple levels of loops is wrap the inner calls in a function and return from them when needed:    def f(x):        for y in y:            for z in Z:                if test1(x,y,z):                    return                frobnicate(x,y

flow control and nested loops

2009-09-25 Thread kj
In Perl, one can label loops for finer flow control. For example: X: for my $x (@X) { Y: for my $y (@Y) { for my $z (@Z) { next X if test1($x, $y, $z); next Y if test2($x, $y, $z); frobnicate($x, $y, $z); } glortz($x, $y); } splat($x); } What's considered

Re: flow control and nested loops

2009-09-25 Thread Simon Forman
On Fri, Sep 25, 2009 at 3:01 PM, kj no.em...@please.post wrote: In Perl, one can label loops for finer flow control.  For example: X: for my $x (@X) {  Y: for my $y (@Y) {    for my $z (@Z) {      next X if test1($x, $y, $z);      next Y if test2($x, $y, $z);      frobnicate($x, $y, $z

Re: flow control and nested loops

2009-09-25 Thread Terry Reedy
kj wrote: In Perl, one can label loops for finer flow control. For example: X: for my $x (@X) { Y: for my $y (@Y) { for my $z (@Z) { next X if test1($x, $y, $z); next Y if test2($x, $y, $z); frobnicate($x, $y, $z); } glortz($x, $y); } splat($x

loops for ffmpeg CLI in python

2009-08-13 Thread fakhar Gillani
Hi, I am a begineer in Python. Actually I am encoding video files with different bitrates using ffmpeg CLI. I wanted to ask you that how can I make loops so that I can vary the bitrates in the CLI of ffmpeg?? I want to bulid a loop for the command below where i just want to vary

Re: loops for ffmpeg CLI in python

2009-08-13 Thread Albert Hopkins
On Wed, 2009-08-12 at 11:29 +0200, fakhar Gillani wrote: Hi, I am a begineer in Python. Actually I am encoding video files with different bitrates using ffmpeg CLI. I wanted to ask you that how can I make loops so that I can vary the bitrates in the CLI of ffmpeg?? I want to bulid

Re: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops

2009-07-26 Thread Ville M. Vainio
On Jul 23, 11:29 pm, Nick Craig-Wood n...@craig-wood.com wrote:  The syntax would be something like:  def work():    showstatus(building)    r = yield runshell(make)    showstatus(installing)    r = yield runshell(make install)    showstatus(Success)  mygui.startwork(work)  #

Re: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops

2009-07-26 Thread Ville M. Vainio
Apologies for the long subject line, here it is again: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops On Jul 21, 7:48 pm, John Nagle na...@animats.com wrote: The idea: To run functions that execute a series of system commands without

Re: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops

2009-07-23 Thread Nick Craig-Wood
Ville Vainio vivai...@gmail.com wrote: Has anyone implementing something like what the subject line indicates? The idea: To run functions that execute a series of system commands without blocking the ui, *and* without adding state machine logic. The syntax would be something

Re: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops

2009-07-21 Thread John Nagle
Ville Vainio wrote: Has anyone implementing something like what the subject line indicates? The idea: To run functions that execute a series of system commands without blocking the ui, *and* without adding state machine logic. At some level, there's going to be state machine logic. You

Re: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops

2009-07-21 Thread Terry Reedy
Ville Vainio wrote: Has anyone implementing something like what the subject line indicates? Your subject line is so long that it is cut off even on my wide screen. Better to repeat the question in the body. -- http://mail.python.org/mailman/listinfo/python-list

Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops

2009-07-20 Thread Ville Vainio
Has anyone implementing something like what the subject line indicates? The idea: To run functions that execute a series of system commands without blocking the ui, *and* without adding state machine logic. The syntax would be something like: def work(): showstatus(building) r = yield

Re: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops

2009-07-20 Thread Ville M. Vainio
On Jul 20, 1:12 pm, Ville Vainio vivai...@gmail.com wrote: Has anyone implementing something like what the subject line ImplentED. I don't think this is that hard to do in the first place, but a generic solution that can be easily tuned for different gui mainloops would be nice. --

Re: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops

2009-07-20 Thread Ville M. Vainio
On Jul 20, 1:12 pm, Ville Vainio vivai...@gmail.com wrote: I imagine runshell() would be implemented in terms of QProcess, or subprocess.Popen/os.system and a worker thread. Actually, the problem is that of general serialization of worker thread operations. That is, it could be something akin

Re: Infinite loops and synchronization

2009-07-14 Thread Aahz
In article mailman.3048.1247462046.8015.python-l...@python.org, Vincent Gulinao vincent.guli...@gmail.com wrote: lst = list() while True: if len(lst) == SOME_NUMBER: return lst Q2: operating on list from threads (mostly appends) must be safe, right (synchronization)?

Re: Infinite loops and synchronization

2009-07-13 Thread Piet van Oostrum
Vincent Gulinao vincent.guli...@gmail.com (VG) wrote: VG lst = list() VG (lst populated by async twisted deferred callbacks) VG while True: VGif len(lst) == SOME_NUMBER: VGreturn lst VG Q1: is this a common OK practice? I'm worried infinite loops hogs memory. VG Q2: operating

Re: Infinite loops and synchronization

2009-07-13 Thread pdpi
On Jul 13, 6:06 am, Vincent Gulinao vincent.guli...@gmail.com wrote: lst = list() (lst populated by async twisted deferred callbacks) while True:         if len(lst) == SOME_NUMBER:                 return lst Q1: is this a common OK practice? I'm worried infinite loops hogs memory. Q2

Re: Infinite loops and synchronization

2009-07-13 Thread Lawrence D'Oliveiro
In message mailman.3048.1247462046.8015.python-l...@python.org, Vincent Gulinao wrote: Q1: is this a common OK practice? I'm worried infinite loops hogs memory. The problem is not that the loop is infinite, but that it busy-waits, hogging CPU. -- http://mail.python.org/mailman/listinfo

Infinite loops and synchronization

2009-07-12 Thread Vincent Gulinao
lst = list() (lst populated by async twisted deferred callbacks) while True: if len(lst) == SOME_NUMBER: return lst Q1: is this a common OK practice? I'm worried infinite loops hogs memory. Q2: operating on list from threads (mostly appends) must be safe, right

[issue6207] Simple For-Loops

2009-06-05 Thread Gabriel Koritzky
New submission from Gabriel Koritzky naoehomeuem...@gmail.com: I don't know if something like this has been said before, so if it did just ignore this. I have noticed that very few programming languages use simple for loops. Python itself doesn't have a really simple one. So here's my

[issue6207] Simple For-Loops

2009-06-05 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: This is not a place for such discussion. Please post on comp.lang.python. -- nosy: +pitrou resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org

[issue5068] tarfile loops forever on broken input

2009-03-22 Thread Lars Gustäbel
Lars Gustäbel l...@gustaebel.de added the comment: I just checked in a fix for the problem, r70523-70527. Thank you very much for your report. -- resolution: - fixed status: open - closed versions: +Python 2.5 ___ Python tracker

Re: a potential pep to extend the syntax of for loops

2009-03-10 Thread pang
This idea has already been proposed and rejected.  But discuss away as you wish ;=). tjr Where is that? I didn't see any related pep's. Could you post a link? -- http://mail.python.org/mailman/listinfo/python-list

Re: a potential pep to extend the syntax of for loops

2009-03-10 Thread Terry Reedy
pang wrote: This idea has already been proposed and rejected. But discuss away as you wish ;=). tjr Where is that? py-dev and/or python-ideas lists within last year I didn't see any related pep's. Though helpful, not too many people write PEPs to document rejections. Could you post a

Re: a potential pep to extend the syntax of for loops

2009-03-10 Thread pang
Sorry, no. tjr well, thank you Even now it's difficult to find the discussion, but at least I know about python-ideas. Thanks to all that replied. -- http://mail.python.org/mailman/listinfo/python-list

Re: a potential pep to extend the syntax of for loops

2009-03-10 Thread Gabriel Genellina
En Tue, 10 Mar 2009 18:28:10 -0200, pang pablo.ang...@uam.es escribió: Even now it's difficult to find the discussion, but at least I know about python-ideas. Try http://blog.gmane.org/gmane.comp.python.ideas -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

a potential pep to extend the syntax of for loops

2009-03-09 Thread pang
Hello, This is an idea about something I'd like to see implemented in python. I understand that's the purpose of PEPs, so I'll write it as a PEP, but send it here to receive your valuable feedback. Abstract This is a proposal to increase the richness of for loops, only to the extent

Re: a potential pep to extend the syntax of for loops

2009-03-09 Thread Chris Rebert
This is a proposal to increase the richness of for loops, only to the extent that it equals that of list and generator comprehensions. In the opinion of the proponent, this will make the language more uniform and would reduce the excessive level of nesting that is required sometimes, without introducing

Re: a potential pep to extend the syntax of for loops

2009-03-09 Thread Lie Ryan
Hello, This is an idea about something I'd like to see implemented in python. I understand that's the purpose of PEPs, so I'll write it as a PEP, but send it here to receive your valuable feedback. Abstract This is a proposal to increase the richness of for loops, only to the extent

Re: a potential pep to extend the syntax of for loops

2009-03-09 Thread pang
for x in range(10) for y in range(10) if x+y==5: print x,y What is that supposed to mean? Nested looping? Why is that (confusing thing) better than: from itertools import product for x, y in product(range(10), range(10)) if x + y == 5:      print x, y That confusing thing is what

Re: a potential pep to extend the syntax of for loops

2009-03-09 Thread Gabriel Genellina
En Mon, 09 Mar 2009 07:15:30 -0200, pang pablo.ang...@uam.es escribió: This is an idea about something I'd like to see implemented in python. The python-ideas list exists to discuss this sort of things. The syntax of a for loop is restricted to the following: for element in list:

Re: a potential pep to extend the syntax of for loops

2009-03-09 Thread Terry Reedy
pang wrote: This is a proposal to increase the richness of for loops, only to the extent that it equals that of list and generator comprehensions. This idea has already been proposed and rejected. But discuss away as you wish ;=). tjr -- http://mail.python.org/mailman/listinfo/python

[issue5068] tarfile loops forever on broken input

2009-01-26 Thread Maciek Fijalkowski
. -- components: Library (Lib) messages: 80567 nosy: fijal severity: normal status: open title: tarfile loops forever on broken input versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue5068] tarfile loops forever on broken input

2009-01-26 Thread Lars Gustäbel
Changes by Lars Gustäbel l...@gustaebel.de: -- assignee: - lars.gustaebel nosy: +lars.gustaebel ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5068 ___

[issue5068] tarfile loops forever on broken input

2009-01-26 Thread Lars Gustäbel
Lars Gustäbel l...@gustaebel.de added the comment: Thanks for the report. The problem is in fact easy to reproduce. _BZ2Proxy hangs if it is passed a file object with either no data or with a partial bzipped file. For example try: tarfile.open(mode=r:bz2, fileobj=StringIO.StringIO()) I will

Re: loops

2008-10-19 Thread Paul Rubin
James Mills [EMAIL PROTECTED] writes: for x in (2**i for i in xrange(10)): print x This is by far the most concise solution I've seen so far. print '\n'.join(str(2**i) for i in xrange(10)) -- http://mail.python.org/mailman/listinfo/python-list

Re: loops

2008-10-19 Thread Steven D'Aprano
On Sat, 18 Oct 2008 20:45:47 -0700, John Machin wrote: On Oct 19, 2:30 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: [snip] making your code easy to read and easy to maintain is far more important. for x in (2**i for i in xrange(10)):     print x will also print 1, 2,

Re: loops

2008-10-19 Thread John Machin
Steven D'Aprano wrote: On Sat, 18 Oct 2008 20:45:47 -0700, John Machin wrote: On Oct 19, 2:30 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: [snip] making your code easy to read and easy to maintain is far more important. for x in (2**i for i in xrange(10)):  

Re: loops

2008-10-19 Thread Steven D'Aprano
On Sun, 19 Oct 2008 03:17:51 -0700, John Machin wrote: Steven D'Aprano wrote: On Sat, 18 Oct 2008 20:45:47 -0700, John Machin wrote: On Oct 19, 2:30 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: [snip] making your code easy to read and easy to maintain is far more

loops

2008-10-18 Thread Gandalf
how can I do width python a normal for loop width tree conditions like for example : for x=1;x=100;x+x: print x thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: loops

2008-10-18 Thread Duncan Booth
Gandalf [EMAIL PROTECTED] wrote: how can I do width python a normal for loop width tree conditions like for example : for x=1;x=100;x+x: print x What you wrote would appear to be an infinite loop so I'll assume you meant to assign something to x each time round the loop as well. The

Re: loops

2008-10-18 Thread Gandalf
On Oct 18, 12:39 pm, Duncan Booth [EMAIL PROTECTED] wrote: Gandalf [EMAIL PROTECTED] wrote: how can I do width python a normal for loop width tree conditions like for example : for x=1;x=100;x+x:     print x What you wrote would appear to be an infinite loop so I'll assume you meant

Re: loops

2008-10-18 Thread robert
Gandalf wrote: On Oct 18, 12:39 pm, Duncan Booth [EMAIL PROTECTED] wrote: Gandalf [EMAIL PROTECTED] wrote: how can I do width python a normal for loop width tree conditions like for example : for x=1;x=100;x+x: print x What you wrote would appear to be an infinite loop so I'll assume you

<    3   4   5   6   7   8   9   10   11   12   >