Prev: What is the differences between tkinter in windows and Tkinter in the other platform?
Next: multiprocessing callbacks?
From: Rhodri James on 14 Dec 2009 18:11 On Mon, 14 Dec 2009 18:40:38 -0000, Colin W. <cjwilliams43(a)gmail.com> wrote: > If your scheme flies, would it be practicable to use the same syntax > as a range generator? > > range(i, j, k) => i:j:k > > so range(10, 2) => :10:2 > > i.e. we could write for i in :10:2: > > or the more common: > range(10) => :10 Ugh. Magic characters. Let's not. -- Rhodri James *-* Wildebeest Herder to the Masses
From: Anh Hai Trinh on 15 Dec 2009 07:42 > > 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__? Indeed! Python 2.6.4 (r264:75706, Oct 27 2009, 06:25:13) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class slice(object): .... @staticmethod .... def __getitem__(sliceobj): .... return sliceobj >>> slice = slice() >>> slice[:] slice(None, None, None) >>> slice[1::-1] slice(1, None, -1) >>> range(10).__getitem__(slice[::2]) [0, 2, 4, 6, 8] ----aht
From: Bearophile on 15 Dec 2009 12:48 Steven D'Aprano: > I've lost all enthusiasm for discussing language enhancements That's probably the main downside of the moratorium. Humans need to play some to keep their will to work and improve things. Bye, bearophile
From: r0g on 15 Dec 2009 17:26 Terry Reedy wrote: > On 12/14/2009 1:10 PM, geremy condra wrote: >> http://www.python.org/dev/peps/pep-3003/ > > The moratorium does not stop proposals for things to be added after the > moratorium ends. But it does show that Guido and the devs are reluctant > to make *any* change to the core syntax of 3.x without really good > reason. Absent that, I would not mind if the syntax remains frozen for > the rest of 3.x. A minor abbreviation that makes the language look more > like Perl will not cut it. > > Terry Jan Reedy > I agree, string slicing syntax is already a little oblique, it certainly doesn't need complicating. Anyway... Simple is better than complex. Readability counts. If the implementation is hard to explain, it's a bad idea. Roger.
From: Gregory Ewing on 16 Dec 2009 19:23 Terry Reedy wrote: > So it would be > MUCH more useful if that notation created a range object. > > for i in [1:n]: ... > > So I would oppose the slice proposal in favor of a range proposal. Another possibility would be to unify range and slice objects so that they're actually the same thing. Then the same notation could be used for both purposes. -- Greg
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: What is the differences between tkinter in windows and Tkinter in the other platform? Next: multiprocessing callbacks? |