import sys module type sys class Foo module foo bar spam eggs sys modu

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import sys
module = type(sys)
class Foo(module):
foo = 'bar'
spam = 'eggs'
sys.modules['foo'] = Foo('foo')
from foo import spam