import os
from ctypes import *
from _ctypes import FreeLibrary
lib = CDLL('./lib.dll')
hlib = lib._handle
del lib
FreeLibrary(hlib)
os.remove('./lib.dll')
os.path.exists('./lib.dll')
Loading Temporary DLLs into Python on Win32