Diez B. Roggisch wrote: ....... >> >> I have a vague feeling that I came across problems in the past about >> the order in which modules were finalized. > > I'm a bit on unsure ground here - so take it with a grain of salt. > > It is for sure that only executing code will refer to a global - the > mere mention of anything can't possibly create a reference (in python at > least) - consider this simple example: > > import random > > def foo(): > print schroedingers_cat > > if random.random() > .5: > schroedingers_cat = "I'm alive!" > > foo() >
yes I guess although foo must know that schroedingers_cat is global it doesn't need to bring it into existence so would fail 50% of the time :) > > So I presume it can very well happen that you will lose a module when > trying to finalize. > > So most probably it is the cleverest solution to make the cleaner as > self-contained as possible, by storing explicit references to things you > might need in the instance itself. But I'm not sure if the transitivity > of dependencies might not kick your ass somewhere anyhow. I think this must be the right approach. Either the resources or the cleaner should hold everything required for cleanup. Probably the resource is the best place. -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list