From: Alex T. <al...@tw...> - 2005-11-19 12:25:18
|
Brian Mahoney wrote: > > In the "for" loop of file f the statement > base.desc.text = line > is SETTING base.desc.text to the latest value of line, > I think you want to be APPENDING the value of each line > > for line in f: # f is enough, no readlines() is necessary > base.desc.text += line # appending > Although correct, this is perhaps not as efficient as it could be - string append isn't terribly fast in Python anyway, and updating the text in the component is a *lot* of work, done for each line. You could instead do: lines = [] for line in f: lines.append(line) base.desc.text = "".join(lines) and it will do large files apparently instantaneously (as opposed to > 10 seconds for the line-by-line method). -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.362 / Virus Database: 267.13.2/170 - Release Date: 15/11/2005 |