Re: Why cannot jump out the loop?

From: Mark McEahern (marklists_at_mceahern.com)
Date: 04/30/04


Date: Thu, 29 Apr 2004 21:44:33 -0500
To: Jinming Xu <cybermanxu@hotmail.com>

Sorry for top-posting: I just wanted to add that in the OP's case, what
he really needs is for not while.

import sys
n = int(sys.argv[1])
for i in range(n):
    print locals()

// m

p.s. Others have already noted that sys.argv returns a sequence of strings.

> Jinming> I have a very simple python program, which includes a while
> Jinming> loop. But to my surprise, it cannot jump out the while
> Jinming> loop. Does anyone know why?
>
> Jinming> Here is the program:
> Jinming> ___________________________
> Jinming> #!/usr/bin/env python
> Jinming> import sys
> Jinming> n=sys.argv[1]
> Jinming> i=0
> Jinming> while i<n:
> Jinming> print "i=",i," n=",n
> Jinming> i+=1
> Jinming> -----------------------------------------------------
>



Relevant Pages

  • Re: Why cannot jump out the loop?
    ... Jinming> loop. ... it cannot jump out the while ... Jinming> import sys ...
    (comp.lang.python)
  • Re: a question about loop
    ... >> around the entire loop by putting it on the 'done' line. ... done> tempfile ... sys 0m0.00s ...
    (comp.unix.shell)
  • Re: Drive performance bottleneck
    ... > Reducing read to 64 blocks per loop ... > sys 0m0.141s ... > ec31224970ddd3fb74501c8e68327e7b sdb ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: file IO
    ... Are you using Windows? ... I doubt that the mmap module's readline knows whether the file was ... I don't find that a "while" loop with mmap.readline is any ... real 0.372s user 0.331s sys 0.031s ...
    (comp.lang.python)
  • Re: Compile-Time Loops in Assembly Language
    ... Betov wrote: ... sys 0m0.001s ... then they both loop and do that loop 100,000 times. ... mov edx, 100000 ...
    (alt.lang.asm)