Today we'll talk about something interesting: closures in Python.
Essentially, a closure is an inner function that returns from an outer function and uses variables from the outer scope (which don't belong to it). The function essentially "closes over" and captures variables from the outer function. You might have seen this, for example, in decorators.
Each closure object is independent; they don't intersect, and each has its own data.
Closures are another step toward OOP, since here we have some state (data) hidden from prying eyes and can only be interacted with via a pre-written interface (function).
Closures can be useful for avoiding the use of globals, as well as in other cases where it's important to prevent our data from being modified in an invalid way, and to ensure that data is accessed only through our logic.
BUT(!), this data can also be accessed with some determination; it's important to understand that there is no complete data hiding.
Join the channel's support team, it'll be interesting)
✔️Boosty https://boosty.to/python_russian/donate
✔️Yumani 410011506612886
Be the first everywhere and always, turn on notifications for new releases 🔔
Watch wherever it's convenient🤩
✔️ https://vk.com/python_russian
✔️ https://rutube.ru/channel/24346352/
✔️ https://dzen.ru/python_russian
✔️ / pythonrussian
✔️ https://t.me/python_russian
#Python #PythonRussian #PyCharm
En esta página del sitio puede ver el video en línea Closures in Python de Duración hora minuto segunda en buena calidad , que subió el usuario Python Russian 21 July 2021, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 19,677 veces y le gustó 1 mil a los espectadores. Disfruta viendo!