Question: When to use closures? So what are closures good for?Answer:Closures can be used to avoid global values and provide data hiding, and can be an elegant solution for simple cases with one or few methods. However, for larger cases with multiple attributes and methods, a class implementation may be more appropriate. |
Is it helpful?
Yes
No
Most helpful rated by users:
- What is Python?
- How do I share global variables across modules?
- How do you set a global variable in a function in Python?
- What type of language is Python? Programming or Scripting?
- Why can\'t I use an assignment in an expression?