[issue43037] Importlib reload by module name (String)

2021-01-27 Thread Stefan Mosoi
Stefan Mosoi added the comment: I understand. I was using to reload some classes that might have changed/added (updates and stuff) without having to reload the hole project. There might be some other ways (i found this, and didn't keep researching after). The documentation didn't warned / in

[issue43037] Importlib reload by module name (String)

2021-01-27 Thread Brett Cannon
Brett Cannon added the comment: Thanks for the idea, Stefan, but I'm going to close this as something we don't want to do. `importlib.reload()` purposefully takes a module object as that's what is going to get mutated/changed and it must already exist. The other importlib functions take a st

[issue43037] Importlib reload by module name (String)

2021-01-27 Thread Stefan Mosoi
Stefan Mosoi added the comment: Also > without having a reference to module itself reload() just gets the name of the module try: name = module.__spec__.name except AttributeError: name = module.__name__ and then if sys.modules.get(name) is not module So it might

[issue43037] Importlib reload by module name (String)

2021-01-27 Thread Stefan Mosoi
Stefan Mosoi added the comment: The motivation behind my request is as follow: I have a dynamic set class (i don't "know" it) and calling __module__ for that class return a string, reload requires Module(and i don't think __module__ will be changed to module). The other functions (import, im

[issue43037] Importlib reload by module name (String)

2021-01-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It works as documented. reload() argument must be a module. If you have only module name, sys.modules is a mapping of module names to modules. It is trivial to combine two things in one line. And why do you want to reload a module by name (without having a

[issue43037] Importlib reload by module name (String)

2021-01-27 Thread Stefan Mosoi
New submission from Stefan Mosoi : Weird behaviour (maybe it's my opinion) in reload from importlib if i do: import importlib import sys import datetime importlib.reload(datetime.timedelta.__module__) I get Typeerror: reload() argument must be a module but if i do import importlib import sys