MCPcopy Index your code
hub / github.com/ipython/ipython / autoreload

Method autoreload

IPython/extensions/autoreload.py:702–805  ·  view source on GitHub ↗

r"""%autoreload => Reload modules automatically %autoreload or %autoreload now Reload all modules (except those excluded by %aimport) automatically now. %autoreload 0 or %autoreload off Disable automatic reloading. %autoreload 1 or %autoreload expli

(self, line="")

Source from the content-addressed store, hash-verified

700 help="Don't ever use new diffing algorithm",
701 )
702 def autoreload(self, line=""):
703 r"""%autoreload => Reload modules automatically
704
705 %autoreload or %autoreload now
706 Reload all modules (except those excluded by %aimport) automatically
707 now.
708
709 %autoreload 0 or %autoreload off
710 Disable automatic reloading.
711
712 %autoreload 1 or %autoreload explicit
713 Reload only modules imported with %aimport every time before executing
714 the Python code typed.
715
716 %autoreload 2 or %autoreload all
717 Reload all modules (except those excluded by %aimport) every time
718 before executing the Python code typed.
719
720 %autoreload 3 or %autoreload complete
721 Same as 2/all, but also but also adds any new objects in the module. See
722 unit test at IPython/extensions/tests/test_autoreload.py::test_autoload_newly_added_objects
723
724 The optional arguments --print and --log control display of autoreload activity. The default
725 is to act silently; --print (or -p) will print out the names of modules that are being
726 reloaded, and --log (or -l) outputs them to the log at INFO level.
727
728 The optional argument --hide-errors hides any errors that can happen when trying to
729 reload code.
730
731 Reloading Python modules in a reliable way is in general
732 difficult, and unexpected things may occur. %autoreload tries to
733 work around common pitfalls by replacing function code objects and
734 parts of classes previously in the module with new versions. This
735 makes the following things to work:
736
737 - Functions and classes imported via 'from xxx import foo' are upgraded
738 to new versions when 'xxx' is reloaded.
739
740 - Methods and properties of classes are upgraded on reload, so that
741 calling 'c.foo()' on an object 'c' created before the reload causes
742 the new code for 'foo' to be executed.
743
744 Some of the known remaining caveats are:
745
746 - Replacing code objects does not always succeed: changing a @property
747 in a class to an ordinary method or a method to a member variable
748 can cause problems (but in old objects only).
749
750 - Functions that are removed (eg. via monkey-patching) from a module
751 before it is reloaded are not upgraded.
752
753 - C extension modules cannot be reloaded, and so cannot be
754 autoreloaded.
755
756 """
757 args = magic_arguments.parse_argstring(self.autoreload, line)
758 mode = args.mode.lower()
759

Callers 2

magic_autoreloadMethod · 0.80
magic_autoreloadMethod · 0.80

Calls 2

parse_argstringMethod · 0.80
checkMethod · 0.45

Tested by 2

magic_autoreloadMethod · 0.64
magic_autoreloadMethod · 0.64