an************@hotmail.com (Anthony_Barker) wrote in message news:<89*************************@posting.google.c om>...
Is it possible to import modules/files that have something other than
the .py extension?
You can use the imp module to achieve this. For example, for a module
called "mymodule" in a source file called "myfile" then
import imp
mymodule = imp.load_source("mymodule", "myfile")
should import the contents of "myfile" as a module which you can use
as normal. The "mymodule" parameter to the load_source function
presumably just ensures that
mymodule.__name__ = "mymodule"
so that anything relying on that has no nasty surprises. Note that, for this
example, you may end up with a file called "myfilec" alongside "myfile".
David