Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39895
| References | <2e07acfb-4f48-4a27-9b06-3d8103325c0f@googlegroups.com> <kfhsc2$ubq$1@ger.gmane.org> <512ABA02.2080709@r3dsolutions.com> <CALwzid=Dobx0F1Gm3E-Oq0vZf8V6SaNmb3j4SBmty1DDAffwLg@mail.gmail.com> <512B15C0.8070106@r3dsolutions.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2013-02-25 09:54 -0700 |
| Subject | Re: Suggested feature: slice syntax within tuples (or even more generally)? |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2509.1361811338.2939.python-list@python.org> (permalink) |
On Mon, Feb 25, 2013 at 12:41 AM, Andrew Robinson <andrew3@r3dsolutions.com> wrote: >> Intuitively, it should result in an infinite loop starting at 0. But >> ranges require a stop value for a very good reason -- it should not be >> this easy to accidentally create an infinite for loop. > > ... > and, besides, the same is true with other constructions of loops.... > > while a: # Damn easy, if a is accidentally true! Notice I specifically said an "infinite *for* loop". While loops are meant to be indeterminate in the number of iterations they will take going into the loop; for loops are not. >> The next problem you run into is that the semantics of negative >> numbers are completely different between slices and ranges. Consider >> this code: >> >> s = (-5:6) >> for i in s: >> print(i) >> for i in range(6)[s]: >> print(i) > > I don't find this difference to be necessary, nor objectionable. > > It is less inconsistent, in my view, to allow that > ([ 1,2,3,4,5 ])[-1:2] produce [5,1,2] than an empty list; > and ([ 1,2,3,4,5])[2:-1] does produce an empty list. > > I have been looking for actual programs that this would break for over two > months now, and I haven't been finding any. I am willing to run any > mainstream application you can find on test-patched python! Yes, I recollect now that we have already had this discussion.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-13 11:00 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? Terry Reedy <tjreedy@udel.edu> - 2013-02-14 00:23 -0500
Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-13 21:54 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-13 21:54 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-14 07:32 +0000
Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 00:36 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-14 08:03 +0000
Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 01:08 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 01:26 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-14 11:58 -0700
Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 14:01 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 14:01 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-14 17:46 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-14 17:46 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-13 22:06 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? Duncan Booth <duncan.booth@invalid.invalid> - 2013-02-14 12:25 +0000
Re: Suggested feature: slice syntax within tuples (or even more generally)? stephenwlin@gmail.com - 2013-02-14 07:56 -0800
Re: Suggested feature: slice syntax within tuples (or even more generally)? Andrew Robinson <andrew3@r3dsolutions.com> - 2013-02-25 01:10 +0000
Re: Suggested feature: slice syntax within tuples (or even more generally)? Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-25 03:28 -0700
Re: Suggested feature: slice syntax within tuples (or even more generally)? Terry Reedy <tjreedy@udel.edu> - 2013-02-25 06:23 -0500
Re: Suggested feature: slice syntax within tuples (or even more generally)? Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-25 09:54 -0700
Re: Suggested feature: slice syntax within tuples (or even more generally)? Andrew Robinson <andrew3@r3dsolutions.com> - 2013-02-25 09:47 +0000
Re: Suggested feature: slice syntax within tuples (or even more generally)? Nobody <nobody@nowhere.com> - 2013-02-26 07:38 +0000
csiph-web