Re: variables bound in moudules are None when module is not completely imported

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 21:24:33 -0200, escribió: On Wed, Feb 25, 2009 at 05:05:28PM -0200, Gabriel Genellina wrote: I'd try to move all the global stuff in that module into a function, "init". Importing the module will always succeed - you have to manually call init() after importing it. i nor

Re: variables bound in moudules are None when module is not completely imported

2009-02-25 Thread chrysn
On Wed, Feb 25, 2009 at 05:05:28PM -0200, Gabriel Genellina wrote: > I'd try to move all the global stuff in that module into a function, > "init". Importing the module will always succeed - you have to manually > call init() after importing it. i normally do that anyway and would also have do

Re: variables bound in moudules are None when module is not completely imported

2009-02-25 Thread Gabriel Genellina
En Wed, 25 Feb 2009 16:48:16 -0200, escribió: update: i've found one, but this only works if the exception is raised at a point determined by the outside. to explain why this is applicable: in the examples, i used `1/0` to raise a zero division exception inside the module whose scope i want to

Re: variables bound in moudules are None when module is not completely imported

2009-02-25 Thread chrysn
On Tue, Feb 24, 2009 at 03:27:19PM +0100, chr...@fsfe.org wrote: > * is there a workaround? > * especially, is there a workaround that works w/o rewriting the > modules that raise the exceptions? (otherwise, wrapping all the > stuff called in the __name__=="__main__" wrapper into a

variables bound in moudules are None when module is not completely imported

2009-02-24 Thread chrysn
when a module being loaded is interrupted by an exception, code blocks that have the module's scope in their environment will later evaluate variables bound to that module to None, instead of preserving that scope (because it is still referenced somewhere) or raising a NameError (for which i see no