Why is the reboot removed from the built-in python switch in python3?

I recently made the switch from python 2 to python 3. Python 3 documentation : β€œ Removed reload (). Imp.reload () ” This actually doesn't say why.

This question describes how this is done now in python 3. Does anyone know why it was removed from the built-in modules and now requires imp or importlib to reboot? When testing a program as it is created using an interactive prompt, rebooting right there by default is super convenient. Obviously, I can bring this back by doing something like

from imp import reload 

This is just another line of code every time you open an interactive tooltip to check the code. What are the reasons for this change?

+5
source share
1 answer

reload() was removed from the built-in modules, as one of the Python Regrets Guido, expressed in the Main Report in OSCON 2002 (slide 6). See PEP 3100 - Various Versions of Python 3.0 for a few changes that track their origin until this conversation.

From the slide, I would say that he expected to use exec() ; which will undoubtedly cover the most common use of iteratively creating some code in an editor and retesting it in an interactive interpreter.

However, when discussing PEP 3121 β€” Initializing and Completing the Extension Module, Guido quickly discovered that he had missed this feature:

Yes; I'm not sure if module reloading continues to be supported in Py3k or not. If not, it should be removed from PEP; if so, this should be indicated.

I already miss the built-in reload (), so I think it should be kept around in one form or another. I expect some reload functions to remain available, perhaps somewhere in the imp module.

So, in short, reload() was removed first, and then, when it was skipped, imp.reload() added. In any case, in fact it was not necessary, of course I rarely use it.

In Python 3.4, the function was ported to importlib.reload() .

+3
source

All Articles