0 votes
1 view
in Python by (47.8k points)

I know it can be done, but I never remember how.

How can you re import a module in python? The scenario is as follows: I import a module interactively and tinker with it, but then I face an error. I fix the error in the .py file and then I want to re-import the fixed module without quitting python. 

How can I do it?

1 Answer

0 votes
by (107k points)

You can re-import a module in python, by using the importlib and its function reload. 

import importlib

importlib.reload(some_module)

If you are using python 3.2 or 3.3 you can use the following code:-

import imp

imp.reload(module)

Related questions

0 votes
1 answer
+3 votes
1 answer
0 votes
1 answer
asked Jul 12, 2019 in Python by Sammy (47.8k points)
0 votes
1 answer
asked Sep 23, 2019 in Python by Sammy (47.8k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...