On 26 May 2005 [EMAIL PROTECTED] wrote:
> One of the worst I think was doing loads of real spazzy stuff trying to > split whole files in to lists of letters and use string methods to find > the first uppercase one. Hi Chris, An approach like this might work. Rather than read the whole thing into a honking big list, though, we can just iterate through it, letter by letter, by using read(1). Here's one way we might do it that way: ### Pseudocode ### currentLine = 1 while True: nextChar = someFile.read(1) if not nextChar: break elif isNewline(nextChar): currentLine += 1 elif isUppercased(nextChar): break print currentLine ###### This approach avoids sucking the whole file into memory, and is a reasonable approach too. Best of wishes! _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor