-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmlist.py
More file actions
42 lines (39 loc) · 776 Bytes
/
mlist.py
File metadata and controls
42 lines (39 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python
#mlist.py
# Chapter 7 Cool Features of Python
# Author: William C. Gunnells
# Rapid Python Programming
# libs
import itertools
def mlist():
print "a"
yield "one"
print "b"
yield "two"
print "c"
yield "three"
print "d"
yield "four"
print "e"
yield "five"
print "f"
yield "six"
print "g"
yield "seven"
print "h"
for i in mlist():
print i
for x,y in zip([0], mlist()):
print x, y
for x,y in zip([0,1,2], mlist()):
print x, y
for x,y in zip([j for j in range(9) if j>5], mlist()):
print x,y
for x,y in zip([j for j in range(9)], mlist()):
print x,y
for x,y in zip([j for j in range(9)], mlist()):
print x
for x,y in zip([j for j in range(9)], mlist()):
print y
list(itertools.islice(mlist(),4))
list(itertools.islice(mlist(),10))