On Mon, 14 Dec 2009 10:03:16 -0800, Dave wrote: > Just as sets may now be written as {3,'hi'}, I propose that slices > should be available using [start:end] syntax. Following example comes > from projecteuler.net problem 166. The Numeric community would also > like this, as would the general python user. The slice notation would > require one ":" between the brackets to differentiate it from a list, > which is similar to the set notation requirement that disambiguates it > from a dictionary. > > Several times now I've wanted python slice notation. Perhaps I'll > write a Python Enhancement Proposal.
Would it suffice to add the equivalent of numpy.s_ as a builtin? > from numpy import s_ > s_[1:2:3] slice(1, 2, 3) > s_[1:2:3, ..., 4:5] (slice(1, 2, 3), Ellipsis, slice(4, 5, None)) Or would it be possible to define "slice" itself so that it implements __getitem__ and __getslice__? -- http://mail.python.org/mailman/listinfo/python-list