[ create a new paste ] login | about

Link: http://codepad.org/fwxLbl7l    [ raw code | output | fork ]

Python, pasted on Dec 14:
1
2
3
4
5
6
7
8
9
10
11
from functools import partial

def list_files():
  for fn in ["example.txt", "data.txt"]:
    def func(fn):
        return "sample contents of %s" % fn
    yield fn, partial(func, fn)

for fn, body in list(list_files()):
  if fn.endswith('.txt'):
    print body()


Output:
1
2
sample contents of example.txt
sample contents of data.txt


Create a new paste based on this one


Comments: