Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97923
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Peter Pearson <pkpearson@nowhere.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: Resetting the Range start in the middle of a loop |
| Date | 23 Oct 2015 17:23:51 GMT |
| Lines | 30 |
| Message-ID | <d8v8p7Fem43U1@mid.individual.net> (permalink) |
| References | <ea58da60-3fb1-46e1-91db-ed48beebfd5c@googlegroups.com> |
| X-Trace | individual.net HO7U4pCGQdB/hewKzFm6mAaaBQJqEZ3AGkHMB94BVj/c9bH7yT |
| Cancel-Lock | sha1:vXTT2Y1AdneRWYrM4I73m1/JjZA= |
| User-Agent | slrn/pre1.0.0-18 (Linux) |
| Xref | csiph.com comp.lang.python:97923 |
Show key headers only | View raw
On Fri, 23 Oct 2015 08:42:53 -0700 (PDT), bigred04bd3@gmail.com wrote: > I am wanting to reset a Range start while a loop is running. here is > what I have: > > s = 1 > for i in range(s, 1000): > # do stuff > for r in range(i, 1000): > # do stuff > s = s + 100 #example > break > > I've also tried to update the i as well, but it just continues on to > the next number as if it was never updated. > > any help would be great The "s = s + 100" cannot affect the outer for loop because by the time it is executed, the expression "range(s, 1000)" has already been evaluated (i.e., it has been turned into an object) and is in the grips of the outer "for" machinery. Beyond that, though, this is a peculiar thing to want to do. If you want to take such liberties with i, then a "for" probably isn't the clearest construction to use. If you share a *slightly* broader view of your goals, the unusually helpful experts in this group might treat us to an informative discussion of elegant ways to get there. -- To email me, substitute nowhere->runbox, invalid->com.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Resetting the Range start in the middle of a loop bigred04bd3@gmail.com - 2015-10-23 08:42 -0700 Re: Resetting the Range start in the middle of a loop John Gordon <gordon@panix.com> - 2015-10-23 17:15 +0000 Re: Resetting the Range start in the middle of a loop Peter Pearson <pkpearson@nowhere.invalid> - 2015-10-23 17:23 +0000 Re: Resetting the Range start in the middle of a loop Steven D'Aprano <steve@pearwood.info> - 2015-10-24 11:05 +1100 Re: Resetting the Range start in the middle of a loop Nobody <nobody@nowhere.invalid> - 2015-10-24 03:13 +0100 Re: Resetting the Range start in the middle of a loop bigred04bd3@gmail.com - 2015-10-23 19:31 -0700
csiph-web