Oltmans wrote:
On May 9, 1:53 am, superpollo ute...@esempio.net wrote:
add = lambda a,b: a+b
for i in reduce(add,a):
print i
This is very neat. Thank you. Sounds like magic to me. Can you please
explain how does that work? Many thanks again.
shorter nicer IMO.
Those
On Sat, 08 May 2010 14:06:33 -0700, Oltmans wrote:
On May 9, 1:53 am, superpollo ute...@esempio.net wrote:
add = lambda a,b: a+b
for i in reduce(add,a):
print i
This is very neat. Thank you. Sounds like magic to me. Can you please
explain how does that work? Many thanks again.
On Sun, 09 May 2010 15:17:38 +1000, Lie Ryan wrote:
On 05/09/10 07:09, Günther Dietrich wrote:
Why not this way?
a = [[1,2,3,4], [5,6,7,8]]
for i in a:
for j in i:
print(j)
1
2
3
4
5
6
7
8
Too simple?
IMHO that's more complex due to the nested
On 05/09/10 19:18, Steven D'Aprano wrote:
On Sun, 09 May 2010 15:17:38 +1000, Lie Ryan wrote:
On 05/09/10 07:09, Günther Dietrich wrote:
Why not this way?
a = [[1,2,3,4], [5,6,7,8]]
for i in a:
for j in i:
print(j)
1
2
3
4
5
6
7
8
Too simple?
IMHO
On Sun, 09 May 2010 22:52:55 +1000, Lie Ryan wrote:
IMHO that's more complex due to the nested loop,
What's so complex about a nested loop?
one more nested tab. That extra whitespaces is quite irritating.
Then say you don't like it, don't try to make a subjective dislike seem
objectively
Hi, I've a list that looks like following
a = [ [1,2,3,4], [5,6,7,8] ]
Currently, I'm iterating through it like
for i in [k for k in a]:
for a in i:
print a
but I was wondering if there is a shorter, more elegant way to do it?
--
Oltmans ha scritto:
Hi, I've a list that looks like following
a = [ [1,2,3,4], [5,6,7,8] ]
Currently, I'm iterating through it like
for i in [k for k in a]:
for a in i:
i think you used te a identifier for two meanings...
print a
but I was wondering if there is a
On Sat, May 8, 2010 at 1:41 PM, Oltmans rolf.oltm...@gmail.com wrote:
Hi, I've a list that looks like following
a = [ [1,2,3,4], [5,6,7,8] ]
Currently, I'm iterating through it like
for i in [k for k in a]:
for a in i:
print a
but I was wondering if there is a
superpollo ha scritto:
Oltmans ha scritto:
Hi, I've a list that looks like following
a = [ [1,2,3,4], [5,6,7,8] ]
Currently, I'm iterating through it like
for i in [k for k in a]:
for a in i:
i think you used te a identifier for two meanings...
print a
but I was wondering if
Oltmans rolf.oltm...@gmail.com writes:
a = [ [1,2,3,4], [5,6,7,8] ]
Currently, I'm iterating through it like
for i in [k for k in a]:
for a in i:
print a
I would prefer:
for i in a:
for v in i:
print v
i.e., not messing with a and avoiding an additional
On Sat, May 8, 2010 at 3:41 PM, Oltmans rolf.oltm...@gmail.com wrote:
Hi, I've a list that looks like following
a = [ [1,2,3,4], [5,6,7,8] ]
Currently, I'm iterating through it like
for i in [k for k in a]:
for a in i:
print a
but I was wondering if there is a
On May 9, 1:53 am, superpollo ute...@esempio.net wrote:
add = lambda a,b: a+b
for i in reduce(add,a):
print i
This is very neat. Thank you. Sounds like magic to me. Can you please
explain how does that work? Many thanks again.
--
http://mail.python.org/mailman/listinfo/python-list
Oltmans ha scritto:
On May 9, 1:53 am, superpollo ute...@esempio.net wrote:
add = lambda a,b: a+b
for i in reduce(add,a):
print i
This is very neat. Thank you. Sounds like magic to me. Can you please
explain how does that work? Many thanks again.
here:
http://tinyurl.com/3xp
Tycho Andersen ty...@tycho.ws wrote:
On Sat, May 8, 2010 at 3:41 PM, Oltmans rolf.oltm...@gmail.com wrote:
Hi, I've a list that looks like following
a = [ [1,2,3,4], [5,6,7,8] ]
Currently, I'm iterating through it like
for i in [k for k in a]:
for a in i:
print a
On Sat, May 8, 2010 at 4:09 PM, Günther Dietrich
gd.use...@spamfence.net wrote:
[snip]
Too simple?
No, not at all. I really only intended to point the OP to itertools,
because it does lots of useful things exactly like this one.
\t
--
http://mail.python.org/mailman/listinfo/python-list
itertools is also written in c, so if you're working with a big nested list
is long it will be a lot faster.
On Sat, May 8, 2010 at 5:40 PM, Tycho Andersen ty...@tycho.ws wrote:
On Sat, May 8, 2010 at 4:09 PM, Günther Dietrich
gd.use...@spamfence.net wrote:
[snip]
Too simple?
No, not at
On 05/09/10 07:09, Günther Dietrich wrote:
Why not this way?
a = [[1,2,3,4], [5,6,7,8]]
for i in a:
for j in i:
print(j)
1
2
3
4
5
6
7
8
Too simple?
IMHO that's more complex due to the nested loop, though I would
personally do it as:
a = [
17 matches
Mail list logo