IDLE, ALT-M and Packages

Manny manny at budget.net
Wed Feb 16 17:00:54 EST 2000


I added the following chunk o' code to IDLE 0.4,
and just re-added it to IDLE 0.5, so I thought I'd
put it up and see what anyone else thinks of it.

This allows loading files in packages with ALT-M

It does not, however, run the file quite correctly.
For example, loading 'Package.Sub' and pressing F5
just gets you 'Sub'
whereas 'import Package.Sub'
imports Package, then Sub
nor does it verify it's actually part of package.
But it may be of convenice to anyone working with a package.

--Manny
-------------------------------
In open_module (line 310 in Idle 0.5):
replace:
(f, file, (suffix, mode, type)) = imp.find_module(name)

with
if('.' in name):
    nl = string.split(name,'.')
    path = apply(os.path.join,nl[:-1]);
    path_list = map(os.path.join,sys.path,[path]*len(sys.path));
    name = nl[-1];
    (f, file, (suffix, mode, type)) = imp.find_module(name,path_list);
else:
    (f, file, (suffix, mode, type)) = imp.find_module(name)




More information about the Python-list mailing list