Module Name Conflicts

Robert Kern rkern at ucsd.edu
Thu Aug 18 22:30:10 EDT 2005


torched_smurf at yahoo.com wrote:
> Robert Kern wrote:
> 
>>Why not copy cmd.py into your package under a different name?
> 
> It offends my sense of modularity. For the record, I'm trying to use
> pdb, the debugger, which in turn uses cmd. So it would be a matter of
> taking pdb.py and hacking it to import a renamed version of cmd... kind
> of messy and not a very good longterm solution. That's not to say I
> won't resort to it if no better options are forthcoming.

A solution more kind to your sensibilities might be to make an auxiliary 
package alongside (rather than inside) yours. No modification to source 
necessary.

   pystdlib/
     __init__.py
     cmd.py
     pdb.py

Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import pystdlib
 >>> from pystdlib import pdb
 >>> pdb.cmd.__file__
'pystdlib/cmd.py'
 >>>

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Python-list mailing list