comprehending comprehensions

Erik Max Francis max at alcyone.com
Sat Jun 14 17:11:16 EDT 2003


Lulu of the Lotus-Eaters wrote:

> So what does this have to do with list comprehensions.  Well, recall
> how
> you would write the set B in math notation.  Subject to the limits of
> my
> keyboard, something like:
> 
>     B = {x | x <- A s.t. P(x)}
> 
> I try to draw the "member of" symbol as "<-" in ASCII.

In this set notation, it's | (sometimes written as a colon) that means
"such that."  Where you wrote "s.t.," you really meant logical and:

	B = {x | x in A and P(x)}

[where `in' is set membership and `and' is logical conjunction].

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ To perceive is to suffer.
\__/  Aristotle




More information about the Python-list mailing list