<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
namekuseijin wrote:
<blockquote
cite="mid:f0b70e0d-31c2-4d95-bec4-0e57e5d3a860@o14g2000vbo.googlegroups.com"
type="cite">
<pre wrap="">On May 4, 9:15 am, David Robinow <a class="moz-txt-link-rfc2396E" href="mailto:drobi...@gmail.com"><drobi...@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">On Mon, May 4, 2009 at 2:33 AM, namekuseijin
<a class="moz-txt-link-rfc2396E" href="mailto:namekuseijin.nos...@gmail.com"><namekuseijin.nos...@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">ls = [(1,2), (3,4), (5, None), (6,7), (8, None)]
[(x,y) for (x,y) in ls if y]
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap="">[(1, 2), (3, 4), (6, 7)]
</pre>
</blockquote>
<pre wrap="">Nope. That filters out 0 as well as None. Not what the OP asked for.
</pre>
</blockquote>
<pre wrap=""><!---->
True. I'm still a C programmer at heart I guess. ah, the flexibility
of 0... ;)
--
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a>
</pre>
</blockquote>
This seems to work for any length tuples :<br>
<br>
>>> a = [(1,2), (3,4, 'goes'), (5,None), (6,7, 8, 'as', None),
(8, None), (9, 0)]<br>
>>> [tup for tup in a if not [e for e in tup if e == None]]<br>
[(1, 2), (3, 4, 'goes'), (9, 0)]<br>
<br>
<br>
</body>
</html>