Git Product home page Git Product logo

ipython-reload's Introduction

ipython-reload

IPython magic command to reload modules on demand

Install

pip install ipython-reload

Use

In [1]: %load_ext ipython_reload

In [2]: from foo import some_function

In [3]: some_function()
Out[3]: 42

In [4]: # open foo.py in an editor and change some_function to return 43

In [5]: %reload some_function

In [6]: some_function()
Out[6]: 43

The %reload magic can reload modules not directly imported, imported modules in the local namespace, and imported variables.

Reloading imported variables may produce unexpected results if the name is generic, such as in the case of __version__. Python does not track the source of where a variable was defined, so this code loops all imported modules, and looks for a matching name, that is the same type as the variable you want to reload. If you have imported a variable using from foo import bar as baz this functionality will not work.

ipython-reload's People

Contributors

sivel avatar

Stargazers

Théo Morales avatar Turtle Kalus avatar Diego Allen avatar  avatar

Watchers

 avatar  avatar

ipython-reload's Issues

cannot initialize type "ProfilerState": an object with that name is already defined

I got the following error after calling %reload on a class name:

libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: generic_type: cannot initialize type "ProfilerState": an object with that name is already defined
Abort trap: 6

This was on iPython 7.17.0, macOS 10.15.6
Any idea about what might be wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.