Loading Modules in PythonΒΆ
Python software is organized in so-called modules. You can think of them
as toolboxes. For instance if you need mathematical functions you
could load the numpy (numerical python) module. Since you need to work
with data taken in modern lab all you really need to do is loading the
LabTools box : LT.box
. It automatically loads several other useful
modules and functions that are then available to you.
There are several ways of loading modules and you can consult the python modules tutorial for detailed information. Here just a short summary with an example: The simplest version is (here the numpy module is used)
In [1]: import numpy
In order to access the (sin) function of the {numpy} module you need to also give the name of the module:
In [2]: x = numpy.sin(5.)
Another possibility is to give it numpy a new name after you imported it:
In [1]: import numpy as np
In [2]: x = np.sin(5.)
or if you do not want to have to enter the module name you can do:
In [1]: from numpy import *
In [2]: x = sin(5.)
The danger here is, that if you have defined sin
in another module
previously it is now redefined.
For the LT.box
module I suggest you do:
In [1]: import LT.box as B # load the LT.box module and call it B
In that way you always know that the function comes from
the tool box. The numpy module is already loaded in the box and you
can access it as B.np
.