Weekly backup.

This commit is contained in:
2022-06-04 12:57:39 +02:00
parent e552583393
commit 015b896f65
68 changed files with 3530 additions and 27 deletions

View File

@@ -0,0 +1,33 @@
:PROPERTIES:
:ID: 831fbfd2-c668-4099-b2d7-ecae734b9ec4
:mtime: 20220519083124
:ctime: 20220516160421
:END:
#+title: Evaluation tardive
* Introduction
#+BEGIN_SRC python :results output
class A:
def function(self):
return A()
a = A()
A = int
print(f"{a.function() = }")
#+END_SRC
#+RESULTS:
: a.function() = 0
* Explications
* Le code contenu dans une fonction n'est exécuté uniquement lorsque celle-ci est invoquée. Ainsi, la référence à la
fonction non déclarée ~A~ par la méthode ~A.function~ ne génère pas d'erreur,
* Durant l'exécution de la méthode ~A.function~,
However, during the execution Python will bind the name A from
the outer scope, which means that function method will return a newly created int instance.
* Références
* [[https://medium.com/@saint_sdmn/10-hardest-python-questions-98986c8cd309][10 Hardest Python Questions - Medium]]