#數(shù)據(jù)庫SQL
reduce( max, map( Camera.pixels, filter(
lambda c: c.brand() == "Nikon", cameras ) ) )
#maybe equals
SELECT max(pixels)
FROM cameras
WHERE brand = “Nikon”
#There.
#cameras is a sequence
#where clause is a filter
#pixels is a map
#max is a reduce
#一行并發(fā)
import urllib2
from multiprocessing.dummy import Pool as ThreadPool
urls = [
'http://www.python.org',
'http://www.google.com',
'http://www.baidu.com',
'http://www.python.org/community/',
'http://www.saltstack.com'
]
#pool = ThreadPool()
pool = ThreadPool(4) # Sets the pool size to 4
result = pool.map(urllib2.urlopen, urls)
pool.close()
pool.join()