Today I Learned
Python Onliner: Filter Prime Numbers
Here is some one-liner from Linghao:一行 Python 能实现什么丧心病狂的功能?,
- Find out prime numbers using
filter(lambda x: all(map(lambda p: x % p != 0, range(2, x))), range(2, n))
- Read csw file:
with open('t.csv', 'r') as f: rows = [line.strip().split(',') for line in f.readlines()]
- Transpose a matrix
m = [ [1,2],[3,4]]
zip(*m)