Listing functions in a file IN ORDER

Irmen de Jong irmen at
Tue Jun 29 17:38:36 CEST 2004

Ian Sparks wrote:

> I have a python file with a number of functions named with the form doX so :
> doTask1
> doThing
> doOther
> The order these are executed in is important and I want them to be executed top-down. They all have the same parameter signature so I'd like to do :
>     for name, func in vars(mymodule).items():
>         if not name.startswith("do") and callable(func):
>             apply(func,my_params)
> but the problem is that the return from vars is not ordered the same as in the file. i.e. it could be 

Just add a list which sums up the function names in the order you want:

functions = ["doTask1", "doThing", "doOther"......]

and iterate over that list?


More information about the Python-list mailing list