Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38826 > unrolled thread
| Started by | stephenwlin@gmail.com |
|---|---|
| First post | 2013-02-13 11:00 -0800 |
| Last post | 2013-02-26 07:38 +0000 |
| Articles | 3 on this page of 23 — 8 participants |
Back to article view | Back to comp.lang.python
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
Page 2 of 2 — ← Prev page 1 [2]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2013-02-25 09:54 -0700 |
| Message-ID | <mailman.2509.1361811338.2939.python-list@python.org> |
| In reply to | #38826 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Robinson <andrew3@r3dsolutions.com> |
|---|---|
| Date | 2013-02-25 09:47 +0000 |
| Message-ID | <mailman.2513.1361814583.2939.python-list@python.org> |
| In reply to | #38826 |
On 02/25/2013 04:54 PM, Ian Kelly wrote: > 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". OK, so tit for tat. Notice I already showed an effective *accidental* "infinite" for loop because I did notice you spoke about a *for* loop. And, obviously, in the case of the while loop I showed -- it was not meant to be True forever. It's a variable, which is subject to change. I really do respect your opinion; but it's one of about 5 people that dominate this list, albeit the same spend a lot of time helping others; Stephen is someone new to me, and I want to encourage his probing of the issue more than I want to advance my view. P.S. I apologize about the e-mail clock, it seems I am sending my local time again -- and it's different from your timezone; I *wish* the python list computer would politely adjust it when *accidents* happen, or my OS's distribution would fix their bug -- but cest la vie. I limp along with the status quo for now.
[toc] | [prev] | [next] | [standalone]
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Date | 2013-02-26 07:38 +0000 |
| Message-ID | <pan.2013.02.26.07.38.34.183000@nowhere.com> |
| In reply to | #38826 |
On Wed, 13 Feb 2013 11:00:15 -0800, stephenwlin wrote: > Would it be feasible to modify the Python grammar to allow ':' to generate > slice objects everywhere rather than just indexers and top-level tuples of > indexers? If you need to be able to easily construct indexing objects, create a helper like: > class Slicer(object): = def __getitem__(self, s): = return s = > s_ = Slicer() > s_[1,2,3] (1, 2, 3) > s_[:] slice(None, None, None) > s_[1:2:3,4:5:6] (slice(1, 2, 3), slice(4, 5, 6)) > s_[...] Ellipsis
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.python
csiph-web