[Tutor] R: Re: Tutor Digest, Vol 131, Issue 59 Order loop from methos on class (jarod_v6 at libero.it)

Alan Gauld alan.gauld at btinternet.com
Mon Jan 26 16:26:27 CET 2015

On 26/01/15 13:54, jarod_v6 at libero.it wrote:
> I initiazlizate the class with the file to use so all the function have all
> the parameters that I need.
> At the moment I have in mind only to do this:
> ena = Rna()
> job1 = ena.trim()
> job2 = ena.align()
> It is no so elegant..

You originally posted a solution where you had a list of methods in an 
attribute called steps. That's a better solution than trying to
iterate over all the methods in the class.

for method in self.steps:

But you don't really tell us what you are trying to do. So its hard to 
determine what an elegant solution is when we don't know the problem we 
are trying to solve.

It looks as if you are trying to create a workflow of some sort?
Does the flow always follow the same sequence - use a list of methods
Does the workflow vary depending on results - use a table where
      the return value of each method indicates which column to
      call next.
Is each method called only once or can it repeat steps?
How are errors to be handled?
Is timing critical?
Do you need to fully process one record at a time or can it be
batch oriented?

There are lots of questions to consider, all of which affect the
"best" solution.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list