[Python-3000] Module name discovery

Fred L. Drake, Jr. fdrake at acm.org
Fri May 5 17:59:59 CEST 2006


On Friday 05 May 2006 11:46, Edward Loper wrote:
 >    3. I have written a patch to python-mode.el that modifies buffer
 >       names to include the package name.  This is especially useful
 >       when you have several different subpackages: seeing
 >       "__init__.py (epydoc.markup)" is much more informative than
 >       "__init__.py<4>".

For this, I use this in my ~/.emacs file:

  (setq uniquify-buffer-name-style 'post-forward)
  (setq uniquify-after-kill-buffer-p t)
  (require 'uniquify)

This creates buffer names based entirely on paths, but that's ok.  It supports 
the case of identically-named modules in completely independent source trees 
as well as different packages within a tree.

It would be nice to have a convenient function that could take a 
sys.path/sys.meta_path configuration provide the module name based on a 
filename, but it really requires that sys.path/sys.meta_path information.  
This won't always be easy for applications that do anything non-trivial to 
prepare those unless tools can run a bit of Python code to get that 
information.  (Or whatever the Py3K equivalent turns out to be.)


  -Fred

-- 
Fred L. Drake, Jr.   <fdrake at acm.org>


More information about the Python-3000 mailing list