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
On this page of the site you can watch the video online Closures in Python with a duration of hours minute second in good quality, which was uploaded by the user Python Russian 21 July 2021, share the link with friends and acquaintances, this video has already been watched 19,677 times on youtube and it was liked by 1 thousand viewers. Enjoy your viewing!