4

I am going through a book on Python which spends a decent time on module reloading, but does not explain well when it would be useful.

Hence, I am wondering, what are some real-life examples of when such technique becomes handy?

That is, I understand what reloading does. I am trying to understand how one would use it in real world.

Edit:

I am not suggesting that this technique is not useful. Instead, I am trying to learn more about its applications as it seems quite cool.

Also, I think people who marked this question as duplicate took no time to actually read the question and how it is different from the proposed duplicate. I am not asking HOW TO reload a module in Python. I already know how to do that. I am asking WHY one would want to reload a module in Python in real life. There is a huge difference in nature of these questions.

6
  • 1
    Apparently this person needed it: stackoverflow.com/questions/437589/… Commented Aug 4, 2017 at 18:19
  • I mean using the from imp import reload and doing something like reload(module_name) Commented Aug 4, 2017 at 18:20
  • 1
    @MadPhysicist Yes, I know. I just realized that. I (mistakenly) thought you were asking this question. Commented Aug 4, 2017 at 18:21
  • @ChristianDean no problem. Commented Aug 4, 2017 at 18:24
  • 2
    The question is about why to do reloading, not how to do reloading. I do not see how it is a duplicate. I propose to reopen it. Commented Aug 4, 2017 at 21:56

2 Answers 2

3

Module reloading (also known as "hot-swapping") is commonly used in long-running systems, such as telephone switch software, that cannot be shut down for maintenance without causing costly service interruption. Such systems are upgraded piece-wise, one module at a time. For example, hot-swapping is natively supported at the implementation level by Erlang.

Python systems rarely run for long time. Real-life module reloading in Python does not seem to be of major importance.

EDIT: As @Aaron suggested, module reloading is used in some Python IDEs to facilitate module development.

Sign up to request clarification or add additional context in comments.

3 Comments

Some IDEs (spyder) provide module re-loading mechanisms within their shell to make developing those modules easier.
@Aaron True. I interpreted "real-life" as "industrial use." One may argue forever if this includes IDEs.
This is an overly simplistic and a little narrow. There are plenty of reasons to reload modules Django is a splendid example of long-running web servers that require it. See the duplicate answer for more detail
0

As an appendix to DYZ's answer, I use module reloading when analysing large data in interactive Python interpreter.

Loading and preprocessing of the data takes some time and I prefer to keep them in the memory (in a module BTW) rather than restart the interpreter every time I change something in my modules.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.