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','ou
On Sep 25, 2:05 pm, Andrew Svetlov wrote:
> On Sep 25, 1:16 pm, Wanderer wrote:
>
> > execfile(x) does what I'm looking for.
>
> Perhaps you are looking for Python import
> hook:http://www.python.org/dev/peps/pep-0302/
>
> In you import hook you can do everything (and locate/import file with
> a
On Sep 25, 1:16 pm, Wanderer wrote:
> execfile(x) does what I'm looking for.
>
Perhaps you are looking for Python import hook:
http://www.python.org/dev/peps/pep-0302/
In you import hook you can do everything (and locate/import file with
any extension :)
--
http://mail.python.org/mailman/listi
On Sep 25, 12:15 pm, Ishwor Gurung wrote:
> Wanderer
> Hi
> Refer tohttp://docs.python.org/tutorial/modules.html#the-module-search-path.
>
> Particularly-
> "
> When a module named spam is imported, the interpreter searches for a
> file named spam.py in the current directory, and then in the list
Wanderer
Hi
Refer to http://docs.python.org/tutorial/modules.html#the-module-search-path.
Particularly-
"
When a module named spam is imported, the interpreter searches for a
file named spam.py in the current directory, and then in the list of
directories specified by the environment variable PYTH
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
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
--
http://mai