module import, but different

Andrew Dalke dalke at bioreason.com
Tue Jun 15 04:04:47 CEST 1999


Tim Peters <tim_one at email.msn.com> said:
> This is much harder than the problem you claimed to have at
> the start

  Well..... yeah.  When I'm not sure what I'm doing, I try
to start off with what I think is the problem.

> Ack, enough already.

  And keep on describing the problem in the hopes that someone
can figure out what I want to do.

> The std imp module packages many functions that will be helpful
> when doing this.

  This is just the pointer I needed.  Once I figured out the right
parameters for imp.load_module, it worked:


val> pwd
/home/u03/dalke/src/MCS/test
val> python
Python 1.5.1 (#21, Nov 23 1998, 15:04:47) [C] on irix6
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import MCS
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ImportError: No module named MCS
>>> import imp
>>> imp.load_module("MCS", None, "..", ("", "r", imp.PKG_DIRECTORY))
>>> import MCS.Daylight
>>> MCS.Daylight.test()
time for standard comparison 0.0091609954834
 MCS size 2
>>> 

  Yet another reason why I like the Python implementation :)


G. David Kuhlman <dkuhlman at netcom.com> chimed in:
> If you decide to follow Tim's suggestion and implement your own
> import, then search DejaNews for "imputil".

  Luckily, this is enough for what I need.

						Andrew Dalke
						dalke at bioreason.com




More information about the Python-list mailing list