Information About Updating Your Own Modules in IPython

Asked 1 years ago, Updated 1 years ago, 55 views

When I save my own functions in a .py file and call them from an external py file, I want to update my own functions frequently, but once I call them from an external py file, I can't update them no matter how many times I import them.

Please let me know how to do it.

For example, if a file containing a self-made function is set to y.py and a program to call を is set to ..py, I would like to change ..py if necessary while trying various things by running ..py.

anaconda ipython

2022-09-30 16:21

1 Answers

Have you seen autoreload?

For example, if there is a script like this in the current directory, foo.py

def say():
    print ("hello")

Enabling the autoreload module from ipython:

In[1]:%load_ext autoreload

In[2]: %autoreload2

The first boot looks like this:

In[3]:from from from import say

In[4]: say()
hello

Rewrite foo.py at this time:

def say():
    print ("world")

This is what happens when you run say() on ipython.

In[5]: say()
world


2022-09-30 16:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.