Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81452
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'interpreter': 0.05; 'output': 0.05; '"""': 0.07; 'string': 0.09; 'exec': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; 'way:': 0.09; 'def': 0.12; '.py': 0.16; '__del__': 0.16; 'a()': 0.16; 'dict': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:created': 0.16; 'wrote:': 0.18; 'module': 0.19; 'patrick': 0.19; 'import': 0.22; 'header:User-Agent:1': 0.23; 'received:comcast.net': 0.24; 'file.': 0.24; 'source': 0.25; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'code': 0.31; 'prints': 0.31; 'subject:skip:i 10': 0.31; 'class': 0.32; 'run': 0.32; 'another': 0.32; 'running': 0.33; 'skip:_ 10': 0.34; 'subject:with': 0.35; 'done': 0.36; 'method': 0.36; 'being': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'new': 0.61; 'charset:windows-1252': 0.65; 'between': 0.67 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Ned Batchelder <ned@nedbatchelder.com> |
| Subject | Re: unloading a module created with imp.new_module |
| Date | Mon, 24 Nov 2014 06:44:10 -0500 |
| References | <C093BC09-3AB7-49DB-B160-265A34C6BCDA@gmail.com> <CALwzidnHV8smFHtvixtdhX-i94PWbwNKSRrR6HAfhn2HOKqxsw@mail.gmail.com> <CALwzid=9Zgu3svDP-mv8-1DrZkKkDcNTxy+D=obwGsOGzB5aZQ@mail.gmail.com> <B8391E6B-5AA4-4125-96BC-74B12B46E927@gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | c-50-133-228-126.hsd1.ma.comcast.net |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
| In-Reply-To | <B8391E6B-5AA4-4125-96BC-74B12B46E927@gmail.com> |
| 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.16246.1416829460.18130.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1416829460 news.xs4all.nl 2929 [2001:888:2000:d::a6]:52476 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:81452 |
Show key headers only | View raw
On 11/23/14 5:10 AM, Patrick Stinson wrote:
> I am defining a single class with a destructor method that prints
> ‘__del__’, and running that source code string using exec with the
> module’s dict like so:
>
> import rtmidi
> importsys
> import types
> importtime
> importgc
>
> s= """
> class A:
> def __del__(self):
> print('__del__')
> a = A()
> """
>
> m = types.ModuleType('mine')
> exec(s, m.__dict__)
> print('deleting...')
> m= None
> print('done')
>
> and the output is:
>
> deleting...
> done
> __del__
>
> I the “__del__" to come between “deleting…” and “done”. This is not
> being run from the interactive interpreter by via a .py file.
>
Let's look at this another way: Why do you need the module to be
unloaded? Isn't it enough to have the new code loaded?
--
Ned Batchelder, http://nedbatchelder.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: unloading a module created with imp.new_module Ned Batchelder <ned@nedbatchelder.com> - 2014-11-24 06:44 -0500
csiph-web