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. -- http://mail.python.org/mailman/listinfo/python-list