Замыкания, декораторы и nonlocal в Python: Путешествие от переменной до элегантного кода

Python славится своей гибкостью. Мы можем передавать функции как аргументы, возвращать их из других функций и даже "записывать" внутрь них состояние. Но как это работает под капотом? И при чем тут странное слово nonlocal ? В этой статье мы проследим эволюцию: начнем с глобальных переменных, разберемся с замыканиями (closures), поймем магию nonlocal , а затем соберем всё это вместе, чтобы понять, как работают декораторы — один из самых элегантных механизмов Python.

https://habr.com/ru/articles/1009132/

#python #global #декораторы #замыкания #функции #nonlocal

Замыкания, декораторы и nonlocal в Python: Путешествие от переменной до элегантного кода

Python славится своей гибкостью. Мы можем передавать функции как аргументы, возвращать их из других функций и даже "записывать" внутрь них состояние. Но как это работает под капотом? И при чем тут...

Хабр

How to Make Functions Remember State

Closure captures variables. Inner function sees outer. State without class.

#python #closure #nonlocal #state #howto

https://www.youtube.com/watch?v=SWt7GwZ_ekM

How to Make Functions Remember State #python

YouTube

Область видимости в Python: LEGB и подводные камни

Работа с переменными в Python кажется очевидной до тех пор, пока код не начинает вести себя неожиданно. Ошибки с UnboundLocalError , странное поведение замыканий или некорректная работа global и nonlocal - всё это следствие непонимания области видимости. В Python действует чёткое правило разрешения имён - LEGB . Разберёмся, как оно работает и какие ловушки скрываются под капотом.

https://habr.com/ru/articles/1002186/

#python #LEGB #nonlocal #global #области_видимости #программирование

Область видимости в Python: LEGB и подводные камни

Работа с переменными в Python кажется очевидной до тех пор, пока код не начинает вести себя неожиданно. Ошибки с UnboundLocalError , странное поведение замыканий или некорректная работа global и...

Хабр
Existence, Time, and the Silent Thread Between Them.

Sanjay Mohindroo

Medium
Existence, Time, and the Silent Thread Between Them.

Sanjay Mohindroo

Medium
Existence, Time, and the Silent Thread Between Them.

Sanjay Mohindroo

Medium

 
Understanding #Quantum #Mechanics #3: #NonLocality

❛❛ #Quantum #Mechanics, it seems, then forces you to give up on #determinism & #locality. It is fundamentally unpredictable & #nonlocal. ❜❜ 5:00/7-min.

🔗 https://www.youtube.com/watch?v=XL9wWeEmQvo 2020 May 29
🔗 https://Wikipedia.org/wiki/Quantum_nonlocality
🎓 h/t @teledyn for thoughts on non-locality.

#Community #TimeTravel #Research #physics #science #spacetime #BellsTheorem #video #Kronodon

Understanding Quantum Mechanics #3: Non-locality

YouTube

#Cells can surf, we maintain, with a revised version of our paper on #arXiv now !

What they need to be is nothing more than the schematic below – a treadmilling bar in frictional contact with a soft elastic substrate. If soft enough, #symmetry breaking occurs because of the #nonlocal #feedback of these friction forces via the substrate and the cell starts to move.

#mechanobiology of #cellmigration
https://arxiv.org/abs/2303.09666

Initiation of motility on a compliant substrate

The conditions under which biological cells switch from a static to a motile state are fundamental to the understanding of many healthy and pathological processes. In this paper, we show that even in the presence of a fully symmetric protrusive activity at the cell edges, such a spontaneous transition can result solely from the mechanical interaction of the cell traction forces with an elastic substrate. The loss of symmetry of the traction forces leading to the cell propulsion is rooted in the fact that the surface loading follows the substrate deformation. The bifurcation between the static and motile states is characterized analytically and, considering the measurements performed on two cell types, we show that such an instability can realistically occur on soft in vivo substrates.

arXiv.org
Challenging Einstein – New Study Suggests That Dark Matter Interacts With Gravity in a Non-Local Way
A new study from SISSA suggests that dark matter interacts with gravity in a non-local way, challenging traditional theories and offering new perspectives on the nature of dark matter. Utilizing fractional calculus, the researchers found that this non-local interaction more accurately describes the motion of stars, especially in small-sized galaxies.
https://scitechdaily.com/challenging-einstein-new-study-suggests-that-dark-matter-interacts-with-gravity-in-a-non-local-way/ #Astronomy #Astrophysics #DarkMatter #Gravity #SISSA #NonLocal
Challenging Einstein – New Study Suggests That Dark Matter Interacts With Gravity in a Non-Local Way

A recent study from SISSA proposes a new model of non-local interaction between the dark matter of a galaxy and gravity. Isaac Newton described his theory of gravity as a force that acts instantaneously across space: a planet immediately senses the effects of another astronomical object, regardless

SciTechDaily
Dark Matter Might Interact in a Totally Unexpected Way With the Universe
In a new study by the International School for Advanced Studies (SISSA) in Trieste, Italy, a team of researchers suggests that Dark Matter might interact with gravity in a non-local way.
https://www.universetoday.com/162193/dark-matter-might-interact-in-a-totally-unexpected-way-with-the-universe/ #Bwahaha ##DarkMatter #universe #unexpected #interraction #nonlocal
Dark Matter Might Interact in a Totally Unexpected Way With the Universe

A new theory of Dark Matter suggests that it interact with normal matter in a non-localized way, potentially revolutionizing our understanding of physics!

Universe Today