On May 11, 2:32 am, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > philly_bob <[EMAIL PROTECTED]> writes: > > algs=['AlgA', 'AlgB', 'AlgC', 'AlgD', 'AlgE'] > > accs=[] > > for alg in algs: > > thisacc=getattr(alg.accuracy)() # picked this technique on > > comp.lang.python last month > > accs.append(thisacc) > > I think what you mean is (untested): > > algs = [AlgA, AlgB, AlgC, AlgD, AlgE] > accs = sorted(((alg.accuracy(), alg.name()) for alg in algs), > reverse=True) > for i,(alg_acc, alg_name) in enumerate(accs): > print '%2d %5s %0.2f'% (i, alg_name, alg_acc) > > This assumes a method alg.name() which tells you the name of the > algorithm. I don't understand how you're converting the string 'AlgA' > to an algorithm object in your example above.
The technique is described in this thread: http://groups.google.com/group/comp.lang.python/browse_frm/thread/ed652ba2fab47a6f/489f1746210e83b9?lnk=st&q=b0bm00r3#489f1746210e83b9 I've barely mastered it, but it does work. Bob= -- http://mail.python.org/mailman/listinfo/python-list