question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autoreload other python files if they've been imported

See original GitHub issue

User scenario:

User has two files, foo.py and bar.py.

They are working in foo.py and they run this cell

from bar import my_func
my_func()

Then they go to bar.py and modify my_func().

They run a cell like so:

#%%
my_func()

It would be nice if my_func automatically picked up the changes from bar without having to redo the import.

The autoreload magic does this already. https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

10reactions
krystophnycommented, Nov 29, 2019

There is an option in the preferences to run startup commands for Interactive Python. Mine is set to "python.dataScience.runStartupCommands": "%load_ext autoreload\\n%autoreload 2"

6reactions
timvinkcommented, Sep 23, 2020

☝️ Syntax has been updated, it’s "python.dataScience.runStartupCommands": ["%load_ext autoreload","%autoreload 2"]

Read more comments on GitHub >

github_iconTop Results From Across the Web

Autoreload other python files if they've been imported #1542
User scenario: User has two files, foo.py and bar.py. They are working in foo.py and they run this cell from bar import my_func...
Read more >
Automatically Reload Modules with %autoreload
If you already imported a module ( import a_module ) or a function ( from a_module import a_function ) in your Python session...
Read more >
Reloading submodules in IPython - Stack Overflow
IPython comes with some automatic reloading magic: %load_ext autoreload %autoreload 2. It will reload all changed modules every time before executing a new ......
Read more >
Jupyter / IPython: After editing a module, changes are not ...
1) The simplest and most certain is to restart the ipython kernel after changing an imported module. But this has downsides as well,...
Read more >
9.8. Reload modified modules — itom Documentation - Bitbucket
Usually, script files (hence modules) that are imported by another script in python are pre-compiled and cached for a faster execution once ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found