En Fri, 13 Jun 2008 22:38:24 -0300, Dan Yamins <[EMAIL PROTECTED]> escribió:
>> Gabriel, thanks. I understood about the fact that import only loads the > first time, but didn't realize that "del" only removes the bound reference > to the object, not as I had hoped the thing from the namespace itself. > > Also, I did _try_ to use reload. however, that failed since .archive was no > longer an attribute associated with Operations: > > >>> import Operations.archive > >>> del Operations.archive > >>> reload(Operations.archive) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > AttributeError: 'module' object has no attribute 'archive' I don't get *why* do you want to remove the 'archive' attribute before reloading the module. Just reload it *without* using `del` previously. > It seems unfortunately that the "del" operation on the one hand doesn't > really remove the .archive from memory but just it's bound name, but > nonetheless prevents me from reloading the object kept in memory. > > I guess I'm trying to find a clean way to remove all the attributes > associated with a module when I reload it. Is there any way to do this? > (The operation of recursively searching through the attributes of the module > and deleting those first seems to be bad since when I did that and then try > to _reload_ the module, the attributes I deleted are _not_ reloaded.) When you reload a module, new definitions for existing names replace the old objects; new names are added; old names without a new value keep the previous value. (That is, objects are *replaced* and *added* but not *removed*). Isn't it enough? Or do you actually want to be sure that old names, now unused, are no longer available? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list