Python Closures Example Code
Posted
by user336527
on Stack Overflow
See other posts from Stack Overflow
or by user336527
Published on 2010-05-09T06:44:15Z
Indexed on
2010/05/09
6:48 UTC
Read the original article
Hit count: 313
I am learning Python using "Dive Into Python 3" book. I like it, but I don't understand the example used to introduce Closures in Section 6.5.
I mean, I see how it works, and I think it's really cool. But I don't see any real benefit: it seems to me the same result could be achieved by simply reading in the rules file line by line in a loop, and doing search / replace for each line read.
Could someone help me to:
either understand why using closures in this example improves the code (e.g., easier to maintain, extend, reuse, or debug?)
or suggest a source of some other real-life code examples where closures really shine?
Thank you!
© Stack Overflow or respective owner