I use a piece of astrophysical software called AMUSE, which uses python command line. I have got the binary release that imports amuse in terminal. Now if I want to run a saved python program in any directory, how do I call it?
Previously I used in terminal
python first.py
pwd=secret;database=master;uid=sa;server=mpilgrim
The first.py looks like this
def buildConnectionString(params):
"""Build a connection string from a dictionary of parameters.
Returns string."""
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
if __name__ == "__main__":
myParams = {"server":"mpilgrim", \
"database":"master", \
"uid":"sa", \
"pwd":"secret" \
}
print buildConnectionString(myParams)
And my codes worked, now I am in python shell
Python 2.7.2 (default, Dec 19 2012, 16:09:14) [GCC 4.4.6] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import amuse
>>>
So if I want the output of any code here, how do I proceed?
I had a program saved in my Pictures/practicepython directory, how can I call that particular .py files in python shell?
with import command, I am getting this error msg
Python 2.7.2 (default, Dec 19 2012, 16:09:14)
[GCC 4.4.6] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import amuse
>>> import first
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named first
>>>