On 05/22/2014 12:32 PM, Xavier de Gaye wrote:
> import 1.py as module_1 on Python 2.7 (module_1 is not inserted in 
sys.modules):
>
>  >>> import imp
>  >>> module_1 = imp.new_module('module_1')
>  >>> execfile('1.py', module_1.__dict__)
>  >>> del module_1.__dict__['__builtins__']


Oups.. should not remove the builtins and should add __file__.
With corrections:

>>> import imp
>>> module_1 = imp.new_module('module_1')
>>> execfile('1.py', module_1.__dict__)
>>> module_1.__file__ = '1.py'

Xavier
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to