Running idle as a package

Jan Decaluwe jand at easics.be
Fri Apr 23 06:52:19 EDT 1999


I was trying to run idle as a package, so I turned the idle
directory into a python package. But then I got:

  Python 1.5.2 (#2, Apr 21 1999, 17:14:19)  [GCC 2.8.1] on sunos5
  Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
  >>> from idle import idle
  Failed to load extension 'SearchBinding'
  Traceback (innermost last):
    File "/usr/local/lib/python1.5/site-packages/idle/EditorWindow.py", line 470, in
load_standard_extensions
      self.load_extension(name)
    File "/usr/local/lib/python1.5/site-packages/idle/EditorWindow.py", line 481, in load_extension
      mod = __import__(name)
  ImportError: No module named SearchBinding
  ...

Apparently the problem is caused by the call to __import__,
that is not aware of the intra-package shortcut.

I have been able to solve this for my case as follows:

  diff -r1.1 EditorWindow.py
  481c481,482
  <         mod = __import__(name)
 ---
  >         pck = __import__('idle.' + name)
  >         mod = getattr(pck, name) 

Regards, Jan

-- 
===================================================================
Jan Decaluwe	          ===              Easics               ===
Design Manager            ===  VHDL-based ASIC design services  ===
Tel: +32-16-395 600	     ===================================
Fax: +32-16-395 619	 Interleuvenlaan 86, B-3001 Leuven, BELGIUM
mailto:jand at easics.be              http://www.easics.com




More information about the Python-list mailing list