importing with .m instead of .py

wisccal wisccal at
Sat Sep 26 17:55:05 CEST 2009

Wanderer wrote:
> Is there a way to get python to import files that don't end in .py?

How about using imp.load_source?

y at x:/tmp$ cat out.m
print("this is my module")
# comment
# comment
y at x:/tmp$ cat
import imp
print("y is {0}".format(MyModule.y))
y at x:/tmp$ p31
this is my module
y is [1, 2, 3, 4, 5, 6, 7, 8, 9]


More information about the Python-list mailing list