sum and strings
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Sun Aug 20 09:05:12 EDT 2006
More information about the Python-list mailing list
Sun Aug 20 09:05:12 EDT 2006
- Previous message (by thread): sum and strings
- Next message (by thread): sum and strings
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In <mailman.9571.1156078160.27775.python-list at python.org>, 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
- Previous message (by thread): sum and strings
- Next message (by thread): sum and strings
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list