Re: enumerate improvement proposal

2006-10-31 Thread Raymond Hettinger
James Stroud wrote: > I think that it would be handy for enumerate to behave as such: > > def enumerate(itrbl, start=0, step=1): >i = start >for it in itrbl: > yield (i, it) > i += step I proposed something like this long ago and Guido has already rejected it. Part of the reason

Re: enumerate improvement proposal

2006-10-31 Thread Steven D'Aprano
On Mon, 30 Oct 2006 23:42:16 +, Steve Holden wrote: > Divorce is obviously the only answer. How could you end up marrying > someone who counts from one and not zero? ;-) "Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration." (Stan

Re: enumerate improvement proposal

2006-10-30 Thread Paddy
James Stroud wrote: > Steve Holden wrote: > > How could you end up marrying > > someone who counts from one and not zero? ;-) > > She's the only other person I've ever met who used vi key binding at the > command line. > Wow. Now I see! It's only Python. Just add one to indices where appropriate,

Re: enumerate improvement proposal

2006-10-30 Thread Ben Finney
Mark Elston <[EMAIL PROTECTED]> writes: > * James Stroud wrote (on 10/30/2006 4:39 PM): > > She's the only other person I've ever met who used vi key binding > > at the command line. > > Well, there's your problem. You need to C-x C-f a new mate. :) I don't have the commitment for that. What if

Re: enumerate improvement proposal

2006-10-30 Thread Mark Elston
* James Stroud wrote (on 10/30/2006 4:39 PM): > Steve Holden wrote: >> How could you end up marrying someone who counts from one and not >> zero? ;-) > > She's the only other person I've ever met who used vi key binding at the > command line. > > James > > Well, there's your problem. You ne

Re: enumerate improvement proposal

2006-10-30 Thread James Stroud
Steve Holden wrote: > How could you end up marrying > someone who counts from one and not zero? ;-) She's the only other person I've ever met who used vi key binding at the command line. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 ht

Re: enumerate improvement proposal

2006-10-30 Thread Steve Holden
James Stroud wrote: > Diez B. Roggisch wrote: > >>>Okay, I've googled "leaky abstractions" (as was probably your intended >>>affect with your silence), read the famous essay, and still >>>don't know what you mean and how it applies to what I have described. >>> >>>Do you plan to justify your state

Re: enumerate improvement proposal

2006-10-30 Thread James Stroud
Diez B. Roggisch wrote: >> Okay, I've googled "leaky abstractions" (as was probably your intended >> affect with your silence), read the famous essay, and still >> don't know what you mean and how it applies to what I have described. >> >> Do you plan to justify your statement or emptily accuse peo

Re: enumerate improvement proposal

2006-10-30 Thread Diez B. Roggisch
> Okay, I've googled "leaky abstractions" (as was probably your intended > affect with your silence), read the famous essay, and still > don't know what you mean and how it applies to what I have described. > > Do you plan to justify your statement or emptily accuse people of violating > esoteric

Re: enumerate improvement proposal

2006-10-30 Thread Anders J. Munch
Ben Finney wrote: > > >>> def obstinate_economist_enumerate(items): > ... enum_iter = iter((i+1, x) for (i, x) in enumerate(items)) > ... return enum_iter iter is redundant here. def natural_enumerate_improvement(items, start=0): return ((i+start, x) for (i, x) in enumer

Re: enumerate improvement proposal

2006-10-29 Thread James Stroud
Fredrik Lundh wrote: > James Stroud wrote: > >> The code is for an economist. She is insistent on starting with the >> first bin as 1. > > > leaky abstractions in reverse, in other words? that's not a good design > approach. > > > Okay, I've googled "leaky abstractions" (as was probably y

Re: enumerate improvement proposal

2006-10-29 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> writes: > >>> print enumerate("ABCDE") > > >>> print list(enumerate("ABCDE")) > [(0, 'A'), (1, 'B'), (2, 'C'), (3, 'D'), (4, 'E')] > > >> def obstinate_economist_enumerate(items): > ... seq = [(i+1, x) for (i, x) in enumerate(items)] >

Re: enumerate improvement proposal

2006-10-29 Thread Ben Finney
James Stroud <[EMAIL PROTECTED]> writes: > Fredrik Lundh wrote: > > why is it this function's job to add an offset to the actual > > sequence index? > > The code is for an economist. She is insistent on starting with the > first bin as 1. Note that 'enumerate' is actually a built-in type, and 'en

Re: enumerate improvement proposal

2006-10-29 Thread Georg Brandl
James Stroud wrote: > I think that it would be handy for enumerate to behave as such: > > def enumerate(itrbl, start=0, step=1): >i = start >for it in itrbl: > yield (i, it) > i += step > > This allows much more flexibility than in the current enumerate, > tightens up code in m

Re: enumerate improvement proposal

2006-10-29 Thread Peter Otten
James Stroud wrote: > I think that it would be handy for enumerate to behave as such: > > def enumerate(itrbl, start=0, step=1): >i = start >for it in itrbl: > yield (i, it) > i += step > > This allows much more flexibility than in the current enumerate, > tightens up code in m

Re: enumerate improvement proposal

2006-10-29 Thread James Stroud
Fredrik Lundh wrote: > James Stroud wrote: > >> The code is for an economist. She is insistent on starting with the >> first bin as 1. > > leaky abstractions in reverse, in other words? that's not a good design > approach. > > > I'm not sure I understand what "leaky abstractions" means. I

Re: enumerate improvement proposal

2006-10-29 Thread Fredrik Lundh
James Stroud wrote: > The code is for an economist. She is insistent on starting with the > first bin as 1. leaky abstractions in reverse, in other words? that's not a good design approach. -- http://mail.python.org/mailman/listinfo/python-list

Re: enumerate improvement proposal

2006-10-29 Thread James Stroud
Fredrik Lundh wrote: > James Stroud wrote: > >> def enumerate(itrbl, start=0, step=1): >>i = start >>for it in itrbl: >> yield (i, it) >> i += step > > that's spelled > > izip(count(start), sequence) > > in today's Python. > > > def in_interval(test, bounds, first=1, rev

Re: enumerate improvement proposal

2006-10-29 Thread James Stroud
Fredrik Lundh wrote: > why is it this function's job to add an offset to the actual sequence > index? > > The code is for an economist. She is insistent on starting with the first bin as 1. I'm guessing, practically, binning linerizes data and the bin number may potentially become a divisor o

Re: enumerate improvement proposal

2006-10-29 Thread Fredrik Lundh
James Stroud wrote: > def enumerate(itrbl, start=0, step=1): >i = start >for it in itrbl: > yield (i, it) > i += step that's spelled izip(count(start), sequence) in today's Python. > def in_interval(test, bounds, first=1, reverse=False): why is it this function's job t

Re: enumerate improvement proposal

2006-10-29 Thread James Stroud
James Stroud wrote: > I think that it would be handy for enumerate to behave as such: > > def enumerate(itrbl, start=0, step=1): > i = start > for it in itrbl: > yield (i, it) > i += step > > This allows much more flexibility than in the current enumerate, > tightens up code in many

enumerate improvement proposal

2006-10-29 Thread James Stroud
I think that it would be handy for enumerate to behave as such: def enumerate(itrbl, start=0, step=1): i = start for it in itrbl: yield (i, it) i += step This allows much more flexibility than in the current enumerate, tightens up code in many cases, and seems that it would break