Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71904
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <xdegaye@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.029 |
| X-Spam-Evidence | '*H*': 0.94; '*S*': 0.00; 'inserted': 0.09; 'subject:script': 0.09; 'python': 0.11; '2.7': 0.14; 'builtins': 0.16; 'subject:import': 0.16; 'xavier': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'header :In-Reply-To:1': 0.27; 'skip:m 30': 0.32; 'received:google.com': 0.35; 'add': 0.35; 'should': 0.36; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'remove': 0.60; 'imp': 0.84; 'subject:All': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=C9WErvIAdAJQSt4IK67blizVzYSUFTBTzoH8i0PBHio=; b=gtMuEUZVhwGPcmRdEnxYIUyyyDduIQQOn0F3vKPRPH6wMdEyTw4ttQkqmLbRgIpDCM IZUH49QUQqmemDWV0b9hiOEJamLbGPXmwv7tz4ZeSQztXaK07ZZYvJ/UQE9/UZyW3DFh 5cRs3k/TW8h8ROh1JWDsZ9XcfX8oed/yM+0EHc0c5Tw7pKcjohxSDzRDJycebgsLYx+g UtndtGCYKoH2gRubFmO/L4gCZ6R8YmzkHyX0iLGLGLKZ+terWjW1EwEgcYs5rWTQGdGl bT1MwbIIcIJ4RzEaEC9I+UoWjJ8j3rcjvIErqmlG/2eEfmEbPrFa6HQtgRdm0w3QOb2Y vx7A== |
| X-Received | by 10.194.90.39 with SMTP id bt7mr1055414wjb.93.1400755898702; Thu, 22 May 2014 03:51:38 -0700 (PDT) |
| Date | Thu, 22 May 2014 12:51:30 +0200 |
| From | Xavier de Gaye <xdegaye@gmail.com> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: All-numeric script names and import |
| References | <CAPTjJmoadqpS0O-15We7xi7SzFCVxTFe1TU8hConcGZzxTRdcA@mail.gmail.com> <537DD23C.1090301@gmail.com> |
| In-Reply-To | <537DD23C.1090301@gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Mailman-Approved-At | Thu, 22 May 2014 19:37:38 +0200 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10229.1400780259.18130.python-list@python.org> (permalink) |
| Lines | 18 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1400780259 news.xs4all.nl 2902 [2001:888:2000:d::a6]:58130 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:71904 |
Show key headers only | View raw
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: All-numeric script names and import Xavier de Gaye <xdegaye@gmail.com> - 2014-05-22 12:51 +0200
csiph-web