View Single Post
Old 2011-06-12, 11:54   #4
Brian Gladman
 
Brian Gladman's Avatar
 
May 2008
Worcester, United Kingdom

523 Posts
Default

The reason why I don't use Python string funtions is that much of this code is a relatively unintelligent tranlation from the original Perl code and this made it convenient to just provide Python equivalents of Perl functions.

Since Perl and Python have radically different philosophies, the translation has resulted in pretty poor Python in many places. This also accounts for some of the redundancy. So there are, I am afraid, a lot of places where the code could be greatly improved.

In the area you are looking at, I might be inclined to use:

Code:
def read_spq(fact_p):
  for j in range(SV_THREADS):
    ql, qp, qh = fact_p['q_dq'][j]
      try:
        with open('.last_spq' + str(100 * PNUM + j), 'r') as in_f:
        try:
          t = int(remove_ws(in_f.readline()))
        except ValueError:
          pass
        if t > qp:
          fact_p['q_dq'][j] = (ql, t, qh)
      except IOError:
        pass
Brian Gladman is offline   Reply With Quote