importing with .m instead of .py

Cesar Koers ckoers at telenet.be
Fri Sep 25 11:35:40 EDT 2009


Wanderer wrote:
> I would like to import Matlab/Octave files of the .m sort into Python
> that look like this.
> 
> # comment
> y=[1,2,3,4,5\
> ,6,7,8,9];
> # comment
> 
> The only problem is I have to change the extensions from .m to .py. Is
> there a way to get python to import files that don't end in .py?
> 
> Thank you
Hi,

(untested:) read the .m file as a string, then evaluate the string (see 
eval()) in appropriate context?


success!

bye




More information about the Python-list mailing list