[0, 0, 0, 1, 1, 1, 0] ... remove all 0 values
D'Arcy J.M. Cain
darcy at druid.net
Wed Jul 8 11:03:15 EDT 2009
- Previous message (by thread): [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values
- Next message (by thread): [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
On Wed, 8 Jul 2009 10:54:09 -0400
ma <mabdelkader at gmail.com> wrote:
> filter(lambda x: x, your_list)
Or...
[x for x in your_list if x]
I'm not sure which one is more efficient but I like the syntax of the
latter. A smart person could probably figure it out even without
knowing Python syntax. Clarity is trump.
--
D'Arcy J.M. Cain <darcy at druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
- Previous message (by thread): [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values
- Next message (by thread): [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Python-list
mailing list