Sol 1) importlib์ reload( ) ํจ์ ์ฌ์ฉ (3.12 ์ดํ imp ์ง์ X)
import example
import importlib
# make changes to example.py file
importlib.reload(example)
๊ธฐ์กด์ sys.path.module์ ๋ฑ๋ก๋ module์ reload ์ํจ๋ค.
์ฃผ์ ํด์ผํ ๊ฒ์ ์ ๋ ๊ฒฝ๋ก์ ์๋ module์ผ ๊ฒฝ์ฐ ์ ๋ ๊ฒฝ๋ก์ ๋ฑ๋ก์ ์์ผ์ค์ผํ๋ค.
Sol 2) JupyterNote Book์์ Magic Command๋ก reload ํ๋ ๋ฐฉ๋ฒ
https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html
autoreload — IPython 8.14.0 documentation
Important This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7. If you are looking for an IPython version co
ipython.readthedocs.io
%load_ext autoreload
%autoreload 2
import example
# make changes to example.py file
Magic Command์ธ %load_ext , %autoreload๋ฅผ ์ฌ์ฉํ๋ค.
%load_ext : ์ ์คํ
%autoreload 2 : 2๋ ์ ์ด ์คํ๋ ๋๋ง๋ค ๋ชจ๋์ด ๋ค์ ๋ก๋ ๋๊ฒ ํ๋ค.
์ดํ ๋ค์ module์ reloadํ๋ฉด ์ต์ ๋ฆด๋ฆฌ์ค๋ ํจํค์ง๋ฅผ ๋ ธํธ๋ฅผ ์ข ๋ฃํ์ง ์๊ณ ์ฌ์ฉํ ์ ์๋ค.
'๐ Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Version] 3.12 rc (Release Candidates) (1) - f-string (0) | 2023.10.18 |
---|---|
[JupyterNote Book] Jupytext Notebook -> Markdown (0) | 2023.09.30 |
Flask - secret_key (1) (0) | 2023.08.09 |
Flask Error : AttributeError: 'Flask' object has no attribute 'login_manager' (0) | 2023.08.08 |
[PEP 703] Making the Global Interpreter Lock Optional in CPython (0) | 2023.07.09 |