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
Auf dieser Seite können Sie das Online-Video Closures in Python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Python Russian 21 July 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 19,677 Mal angesehen und es wurde von 1 tausend den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!