Oltmans wrote:
On May 9, 1:53 am, superpollo 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 alternatives are intere
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
obj
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
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?
>
>
On Sat, 08 May 2010 14:06:33 -0700, Oltmans wrote:
> On May 9, 1:53 am, superpollo 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.
Don't use t
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 d
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 wrote:
> On Sat, May 8, 2010 at 4:09 PM, Günther Dietrich
> wrote:
> [snip]
> > Too simple?
>
> No, not at all. I really only intended to p
On Sat, May 8, 2010 at 4:09 PM, Günther Dietrich
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
Tycho Andersen wrote:
>On Sat, May 8, 2010 at 3:41 PM, Oltmans 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 wond
Oltmans ha scritto:
On May 9, 1:53 am, superpollo 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
and here:
http://tin
On May 9, 1:53 am, superpollo 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
On Sat, May 8, 2010 at 3:41 PM, Oltmans 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 shorter, more el
Oltmans 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 list.
> but I wa
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
On Sat, May 8, 2010 at 1:41 PM, Oltmans 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 shorter, more el
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 s
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?
--
http://mail.python.org/mailman/listinfo/
17 matches
Mail list logo