diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-01-07 13:35:36 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-01-07 13:35:36 +0100 |
commit | 3b69052de6652a0ae30083e04439ecd61c6d91ba (patch) | |
tree | 508b5d9c361358eee4c4816c80a33049eccbb847 /Python.wiki | |
parent | lör 7 jan 2023 13:35:26 CET (diff) | |
parent | lör 31 dec 2022 01:16:21 CET (diff) | |
download | wiki-public-3b69052de6652a0ae30083e04439ecd61c6d91ba.tar.gz wiki-public-3b69052de6652a0ae30083e04439ecd61c6d91ba.tar.xz |
Merge branch 'master' of git.hornquist.se:git/wiki-public
Diffstat (limited to 'Python.wiki')
-rw-r--r-- | Python.wiki | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/Python.wiki b/Python.wiki index e221599..5df7d2e 100644 --- a/Python.wiki +++ b/Python.wiki @@ -1,7 +1,31 @@ +%title Python -== Imports are lazy == +[[PEP3131]] -=== main.py === += Properties = +property + +{{{python +field = property(get_f, set_f) +}}} + +{{{python +class C: + def __init__(self): + self._x = 10 + + @property + def x(self): + return self._x + + @x.setter + def x(self, value): + self._x = value +}}} + += Imports are lazy = + +== main.py == {{{python import sys @@ -17,13 +41,13 @@ match sys.argv: }}} -=== a.py === +== a.py == {{{python print('Importing a') x = 10 }}} -=== b.py === +== b.py == {{{python print('Importing b') x = 20 |