Chapters:
|
MuSR /
Python< ASE initial trial | Index | PyMinuit, how to install and use it > Building a function, matlab style (see /homerdr/ipython/ eg_function.py, fib.py) A module is a file containing Python definitions and statements If it contains a list of commands it is like a script The equivalent of function [out]=fctname(in) .... out=... is def fctname(in): .... # notice the indent return out and it does not require to be stored in a file of the same name, e.g. store it in casual.py To run fctname IN=... import casual as cs cs.fctname(IN) When writing and correcting use reload, e.g. if you imported fb, reload(fb) Write documentation within two """, use line feeds and indents, to read formatted documentation use print module.function.__doc__ < ASE initial trial | Index | PyMinuit, how to install and use it > |