Nov-30-2020, 08:38 AM
I'm not completely certain what is happening, but it looks like the tuple construction is getting confused by the generator. Building up the tuple in the loop "works".
That said, this whole thing is highly suspect.
That said, this whole thing is highly suspect.
def imp3(*Names): modules = tuple() for name in Names: exec("import "+name) print(eval(name)) modules += (eval(name),) return modules os,json, time = imp3("os","json","time") print(os.name) print(time.time())
Output:<module 'os' from '/usr/lib/python3.8/os.py'>
<module 'json' from '/usr/lib/python3.8/json/__init__.py'>
<module 'time' (built-in)>
posix
1606725446.456842