unloading a module created with imp.new_module

Chris Angelico rosuav at gmail.com
Tue Nov 25 01:51:08 EST 2014


On Tue, Nov 25, 2014 at 5:48 PM, Patrick Stinson <patrickkidd at gmail.com> wrote:
> Is it still possible to import non-module objects? I guess this question is
> just for fun now :)

rosuav at sikorsky:~$ python3
Python 3.5.0a0 (default:23ab1197df0b, Nov 20 2014, 12:57:44)
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.modules["hello"]=lambda s: print("Hello, %s!"%s)
>>> import hello
>>> hello("world")
Hello, world!
>>>

ChrisA



More information about the Python-list mailing list