list = [] tuple = () dict = {}
A Pythonic interpretation of a well-known notation for sets used by mathematicians. For example, it is commonly understood that this:
- {x | x > 10}
refers to the set of all x such that x > 10. In math, this form implies a universal set that is understood by the reader (for example, the set of all reals, or the set of all integers, depending on the context). In Python, there is no concept of a universal set, and in Python 2.0, there were no sets. (Sets are an interesting story, of which more in a future blog post.)
This and other considerations led to the following notation in Python:
- [f(x) for x in S if P(x)]
more examples:
- [str(round(355/113.0, i)) for i in range(1,6)]
- urls = [link['href'] for link in links]
A Venn diagram is just a few simple Set operations. Python has this stuff built into the Set datatype. Basically, take your two groups of items and use set operations (e.g. use intersection to find the common items).
https://github.com/adamlabadorf/pyvenn