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...@x:/tmp$ cat out.m
print("this is my module")
# comment
y=[1,2,3,4,5,6,7,8,9];
# comment
y...@x:/tmp$ cat load_my_module.py
import imp
MyModule=imp.load_source('MyModule','out.m')
print("y is {0}".format(MyModule.y))
y...@x:/tmp$ p31 load_my_module.py
this is my module
y is [1, 2, 3, 4, 5, 6, 7, 8, 9]

Regards
wisccal
http://skre.ch

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to