Reputation: 15094
Coming from a Matlab background, I wanted to write small functions in python, and test them individually in the interpreter. However, every time I start the interpreter, I have to import all the modules. In contrast, with matlab all you do is give it the path to the directory and you can execute any matlab function through the interpreter without worrying what to import.
Is there any way the python interpreter could do this?
Upvotes: 4
Views: 920
Reputation: 5514
I also consider myself a MATLAB user who is converting to Python. "ipython -pylab" (from a unix shell or mac terminal shell) does a pretty good job of setting up the variables and functions I use for MATLAB-type computing.
Also - although I found it a pain to install on my mac - I like Spyder for its resemblance to the MATLAB IDE. In the Spyder environment - as in MATLAB - you can run scripts (.py files as compared to the .m files in MATLAB) in the interactive window, which can perform the imports. Then you can type interactively into the window, using the functions you imported. As compared to "ipython -pylab" and autoimport, this will allow you to only import the functions/variables that you desire and keep your workspace uncluttered. For now, this may not be of interest, but eventually it could come in handy.
Upvotes: 0
Reputation: 2140
Try autoimp. Example from the webpage:
>>> from autoimp import *
>>> os.stat('.')
>>> Image.open('test.bmp')
>>> pylab.plot([1,2],[3,4])
>>> scipy.linalg.eig([[1,2],[3,4]])
Upvotes: 7