usr bin env python coding utf-8 def print return def f1 for in xrange

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python
#coding:utf-8
def f(n):
print n,
return n
def f1(n):
for i in xrange(n):
yield (f(i))
def f2(n):
return [f(x) for x in xrange(n)]
def f3(n):
return (f(x) for x in xrange(n))
for func in (f1, f2, f3):
for x in func(3):
print x,
print '\n' + '='*20