In <[EMAIL PROTECTED]>, Gerhard Fiedler
wrote:
> On 2006-08-20 07:18:44, Rhamphoryncus wrote:
>
>>> shallow = []
>>> [shallow.extend(i) for i in deep]
>>
>> I'm sure this has been mentioned before, but listcomps are for when you
>> want to store the list and use it for further things, not for when you
>> want a side effect. TOOWTDI.
>
> Can you please explain what you mean with this, and maybe why?
You should not abuse list comps just to have a one liner. Only use them
if you really want to build a list and not just for side effects. The
above one-liner builds a list of `None`\s of length ``len(deep)`` for no
reason just to throw them away.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list