[Patches] [ python-Patches-441791 ] Improvment to package import semantics

noreply@sourceforge.net noreply@sourceforge.net
Mon, 16 Jul 2001 12:34:14 -0700


Patches item #441791, was opened at 2001-07-16 12:34
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=441791&group_id=5470

Category: core (C code)
Group: 2.0.1 bugfix
Status: Open
Resolution: None
Priority: 5
Submitted By: Alex Coventry (alex_coventry)
Assigned to: Nobody/Anonymous (nobody)
Summary: Improvment to package import semantics

Initial Comment:
I think it's nice to be able to do this:

>>> import sys
>>> sys.path.append('/l/alex_c/')
>>> import mouse.foo
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/l/alex_c/mouse/foo.py", line 1, in ?
    bar
NameError: name 'bar' is not defined
>>> import mouse.foo
>>> reload(mouse.foo) # Works now that foo.py is
corrected
<module 'mouse.foo' from '/l/alex_c/mouse/foo.py'>
>>> from mouse import foo
>>> foo.bar
1

However, at the moment, that's not possible, because if
an error occurs
in the loading of foo, foo is not added to mouse's
dictionary, even
though the module added to sys.modules under the key
'mouse.foo'.  This
has been driving me nuts, because I have large datasets
that I need to
load in each time I start python up, so I tend to test
my scripts in a
single interactive interpreter as I write them, so it's
important for me
to be able to reliably reload modules.  I think it's
also a sensible way
for things to work in general, too.  If there's enough
controversy about
this, I can write a PEP about it, or something.  At any
rate, here's a
patch against the current CVS repository that changes
the semantics as
I've described.

Alex.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=441791&group_id=5470