Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
On Jun 8, 9:40 pm, John Salerno [EMAIL PROTECTED] wrote:
Mensanator wrote:
Heh heh, don't worry. Every time I see a range function, I immediately
think creates a list. Not sure how I got into that habit, but it
happens
On Jun 8, 11:11 pm, Mensanator [EMAIL PROTECTED] wrote:
On Jun 8, 4:04 am, Lie [EMAIL PROTECTED] wrote:
On Jun 8, 8:56 am, Mensanator [EMAIL PROTECTED] wrote:
On Jun 7, 8:22�pm, John Salerno [EMAIL PROTECTED] wrote:
Mensanator wrote:
What I DID say was that how the builtins
this in a
list comprehension where he doesn't have the option of
iterating through both lists like he does with zip.
When I mentioned that could be solved by enumerate, I said
it simultaneously guaratees that the index numbers automatically
end up the same length as the target list and avoids the
hypothetical
Mensanator wrote:
On Jun 6, 1:40 pm, The Pythonista [EMAIL PROTECTED] wrote:
On Thu, 05 Jun 2008 23:42:07 -0400, John Salerno wrote:
Is it possible to write a list comprehension for this so as to produce a
list of two-item tuples?
base_scores = range(8, 19)
score_costs = [0, 1, 1, 1, 1, 1, 1,
On Jun 9, 7:06 am, Ricardo Aráoz [EMAIL PROTECTED] wrote:
Mensanator wrote:
On Jun 6, 1:40 pm, The Pythonista [EMAIL PROTECTED] wrote:
On Thu, 05 Jun 2008 23:42:07 -0400, John Salerno wrote:
Is it possible to write a list comprehension for this so as to produce a
list of two-item tuples?
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Jun 7, 6:43?pm, Terry Reedy [EMAIL PROTECTED] wrote:
| zip(range(9,20), iterable)
|
| Oh, dear. You didn't actually try this, did you?
Works fine in Py3, which is what I use now.
--
On Jun 8, 12:24 am, Mensanator [EMAIL PROTECTED] wrote:
On Jun 7, 5:21�am, Paul Miller [EMAIL PROTECTED] wrote:
On Fri, 06 Jun 2008 18:01:45 -0700, Mensanator wrote:
What happens if your iterables aren't the same length?
I chose not to consider that case,
That's a bad habit to teach a
On Jun 8, 8:56 am, Mensanator [EMAIL PROTECTED] wrote:
On Jun 7, 8:22�pm, John Salerno [EMAIL PROTECTED] wrote:
Mensanator wrote:
What I DID say was that how the builtins actually
work should be understood and it APPEARED that the
OP didn't understand that. Maybe he understood that
On Jun 8, 3:19�am, Terry Reedy [EMAIL PROTECTED] wrote:
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Jun 7, 6:43?pm, Terry Reedy [EMAIL PROTECTED] wrote:
| zip(range(9,20), iterable)
|
| Oh, dear. You didn't actually try this, did you?
Works fine in
On Jun 8, 4:04 am, Lie [EMAIL PROTECTED] wrote:
On Jun 8, 8:56 am, Mensanator [EMAIL PROTECTED] wrote:
On Jun 7, 8:22�pm, John Salerno [EMAIL PROTECTED] wrote:
Mensanator wrote:
What I DID say was that how the builtins actually
work should be understood and it APPEARED that the
Mensanator wrote:
On Jun 8, 3:19�am, Terry Reedy [EMAIL PROTECTED] wrote:
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Jun 7, 6:43?pm, Terry Reedy [EMAIL PROTECTED] wrote:
| zip(range(9,20), iterable)
|
| Oh, dear. You didn't actually try this, did you?
On Jun 8, 9:40 pm, John Salerno [EMAIL PROTECTED] wrote:
Mensanator wrote:
On Jun 8, 3:19�am, Terry Reedy [EMAIL PROTECTED] wrote:
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Jun 7, 6:43?pm, Terry Reedy [EMAIL PROTECTED] wrote:
| zip(range(9,20),
On Fri, 06 Jun 2008 18:01:45 -0700, Mensanator wrote:
What happens if your iterables aren't the same length?
I chose not to consider that case, since they were the same length in the
original post. Based on the variable names, it seemed reasonable that
there would always be a 1-to-1
On Jun 7, 5:21�am, Paul Miller [EMAIL PROTECTED] wrote:
On Fri, 06 Jun 2008 18:01:45 -0700, Mensanator wrote:
What happens if your iterables aren't the same length?
I chose not to consider that case,
That's a bad habit to teach a newbie, isn't it?
since they were the same length in the
Mensanator wrote:
Surely enumerate() wasn't added to Python with no intention of
ever being used.
I see your reasons for preferring enumerate over zip, but I'm wondering
if using enumerate this way isn't a little hackish or artificial. Isn't
the point of enumerate to get the index of a
On Jun 7, 1:16�pm, John Salerno [EMAIL PROTECTED] wrote:
Mensanator wrote:
Surely enumerate() wasn't added to Python with no intention of
ever being used.
I see your reasons for preferring enumerate over zip,
It's not that I prefer it, it's that you specifically
asked a list comprehension
John Salerno [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| Mensanator wrote:
|
| Surely enumerate() wasn't added to Python with no intention of
| ever being used.
|
| I see your reasons for preferring enumerate over zip, but I'm wondering
| if using enumerate this way isn't a
* I never said a for..loop was preferable.
What I said was the answer to Can I do this with
a list comprehension?
I never said you shouldn't use the builtins.
What I DID say was that how the builtins actually
work should be understood and it APPEARED that the
OP didn't understand that. Maybe he
Mensanator wrote:
What I DID say was that how the builtins actually
work should be understood and it APPEARED that the
OP didn't understand that. Maybe he understood that
all along but his example betrayed no evidence of
that understanding.
Well, the truth is that I know zip truncates to the
On Jun 7, 7:21 pm, Paul Miller [EMAIL PROTECTED] wrote:
On Fri, 06 Jun 2008 18:01:45 -0700, Mensanator wrote:
What happens if your iterables aren't the same length?
I chose not to consider that case, since they were the same length in the
original post. Based on the variable names, it
On Jun 7, 8:22�pm, John Salerno [EMAIL PROTECTED] wrote:
Mensanator wrote:
What I DID say was that how the builtins actually
work should be understood and it APPEARED that the
OP didn't understand that. Maybe he understood that
all along but his example betrayed no evidence of
that
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Jun 5, 10:42?pm, John Salerno [EMAIL PROTECTED] wrote:
| Is it possible to write a list comprehension for this so as to produce
a
| list of two-item tuples?
|
| base_scores = range(8, 19)
| score_costs = [0, 1, 1, 1,
On Jun 6, 8:44 am, Terry Reedy [EMAIL PROTECTED] wrote:
Of course, enumerate(iterable) is just a facade over zip(itertools.count(),
iterable)
So you could write:
gen = (x for x in itertools.izip(itertools.count(8), [0, 1, 1, 1, 1,
1, 1, 2, 2, 3, 3]))
print list(gen)
Using zip like you own
On Thu, 05 Jun 2008 23:56:40 -0700, dwahli wrote:
On Jun 6, 8:44 am, Terry Reedy [EMAIL PROTECTED] wrote:
Of course, enumerate(iterable) is just a facade over zip(itertools.count(),
iterable)
So you could write:
gen = (x for x in itertools.izip(itertools.count(8), [0, 1, 1, 1, 1,
1, 1,
Terry Reedy [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Which is exactly the purpose of zip, or its specialization enumerate!
Thanks guys! Looks like the simplest is always the best yet again! :)
--
On Jun 6, 1:44 am, Terry Reedy [EMAIL PROTECTED] wrote:
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Jun 5, 10:42?pm, John Salerno [EMAIL PROTECTED] wrote:
| Is it possible to write a list comprehension for this so as to produce
a
| list of two-item tuples?
|
On Thu, 05 Jun 2008 23:42:07 -0400, John Salerno wrote:
Is it possible to write a list comprehension for this so as to produce a
list of two-item tuples?
base_scores = range(8, 19)
score_costs = [0, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3] print zip(base_scores,
score_costs)
score_costs =
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
On Jun 6, 1:44 am, Terry Reedy [EMAIL PROTECTED] wrote:
Mensanator [EMAIL PROTECTED] wrote in message
And since the OP foolishly
hardcoded his range bounds
Hmm, I just love the arrogance of some people. I actually posted a
On Jun 6, 3:19 pm, John Salerno [EMAIL PROTECTED] wrote:
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
On Jun 6, 1:44 am, Terry Reedy [EMAIL PROTECTED] wrote:
Mensanator [EMAIL PROTECTED] wrote in message
And since the OP foolishly
hardcoded his range bounds
Hmm,
On Jun 6, 1:40 pm, The Pythonista [EMAIL PROTECTED] wrote:
On Thu, 05 Jun 2008 23:42:07 -0400, John Salerno wrote:
Is it possible to write a list comprehension for this so as to produce a
list of two-item tuples?
base_scores = range(8, 19)
score_costs = [0, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3]
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
On Jun 6, 1:44 am, Terry Reedy [EMAIL PROTECTED] wrote:
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Jun 5, 10:42?pm, John Salerno [EMAIL PROTECTED] wrote:
| Is it possible to write a list
On Jun 6, 10:33 pm, Terry Reedy [EMAIL PROTECTED] wrote:
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
On Jun 6, 1:44 am, Terry Reedy [EMAIL PROTECTED] wrote:
Mensanator [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Jun 5, 10:42?pm, John
Is it possible to write a list comprehension for this so as to produce a
list of two-item tuples?
base_scores = range(8, 19)
score_costs = [0, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3]
print zip(base_scores, score_costs)
I can't think of how the structure of the list comprehension would work
in this
On Jun 5, 10:42�pm, John Salerno [EMAIL PROTECTED] wrote:
Is it possible to write a list comprehension for this so as to produce a
list of two-item tuples?
base_scores = range(8, 19)
score_costs = [0, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3]
print zip(base_scores, score_costs)
I can't think of how
34 matches
Mail list logo