3 ms·
To quote the Zen of Python: Flat is better than nested. Too many levels of nesting is definitely a code smell. Often it's better to pull those helper func
by nvader 11y ago
To quote the Zen of Python:
Flat is better than nested.
Too many levels of nesting is definitely a code smell. Often it's better to pull those helper functions out, and/or create function or method factory functions at a higher level of organization.
- Retra 11y agoYou can't really do that if you're writing closures.
- zo1 11y agoHave you had a look at https://docs.python.org/2/library/functools.html#functools.partial https://docs.python.org/2/library/functools.html#functools.p... ? Anywho, do you have a genuine example of where a closure is helpful for you in python? I'm very curious.
- Retra 11y agoI don't understand the question. Your link has examples of closures right in it, so naturally if you're doing anything like that, you'll want them.