Re: import module by filename

Steven D. Majewski (sdm7g@elvis.med.virginia.edu)
Wed, 23 Mar 1994 12:49:26 -0500

On Mar 23, 11:23, "Daniel W. Connolly" wrote:
>
> In message <199403231713.AA28143@elvis.med.Virginia.EDU>, "Steven D. Majewski"
> writes:
>
> >If you wanted connolly_uri to extend and replace module URI in
> >all of the code that imported URI you could name IT URI.py and
> >place it in a directory searched before the library where the
> >original URI.py lived.
>
> Nope... this is the sort of thing I'm trying to avoid: installation
> instructions that say "stick this in your PYTHONPATH so that it
> goes before your normal python library." There's no guarantee that
> two packages don't have conflicting requirements on the order of
> directories.
>

Well - I wasn't necessarily advising this method. The operative word
there was "COULD". Sometimes that IS the appropriate thing to do, but
I was pointing out that there are SOME cases where it just doesn't
work well.

I'm going to put SOME sort of path processing in the next version,
so suggestions are welcome. ( One possibility: an optional pathlist -
if passed it will search on that path. sys.path or some slice of it
could be passed to restrict the search. )

[ unrelated topic - but connected in my mind via "import" ]:

BTW: Has anyone done any hacking of the Mac version of Python to
make it use resource file-forks ?
A couple of possibilities suggest itself:
* dynamic loading of compiled modules on the Mac via code resources.
[ It would be REALLY NEAT to be able to distribute new code modules
to Mac-ers without a development system to compile it on! ]
* put pyc byte code into the resource fork of the py file, rather
than a separate file. [ which may be able to speed up imports ]
* an option to save pyc code into the Python application's resource
fork - a sort of builtin bytecode module. Might give a method of
creating stand alone Python applications on Mac.

Are there many Mac-Python users out there ?
( Please raise your 16-ton Icon, if you are there! :-)

[ I haven't done any Mac hacking for a while, but the POWER-MAC
release ( using the next generation of the same RISC I've got
on my AIX machine ) has got me itching! ]

- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU>
- UVA Department of Molecular Physiology and Biological Physics