---------- Forwarded message ---------- From: Danny Yoo <d...@hashcollision.org> Date: Mon, Oct 6, 2014 at 11:23 AM Subject: Re: [Tutor] grave confusion To: Clayton Kirkwood <c...@godblessthe.us>
> Well the guide certainly doesn't suggest that the read is one character at a > time, it implies one line at a time. However, it's hard to argue against the > one character because that is what the output is looking at. I thought it > would read one line in per iteration. Why didn't they call it readchar()? I think you might still be confused. Here, let's look at it again from a different angle. #################### for line in file.readline(): ... #################### I'm going to make a small change to this: #################### seq = file.readline() for line in seq: ... #################### I've introduced a temporary variable. This should preserve the rough meaning by just giving a name to the thing we're walking across. One more change: #################### seq = file.readline() for thing in seq: ... #################### Again, meaning preserving, if we change every instance of "line" in "..." with "thing". But "thing" is a poor name for this as well. What's its type? If seq is a string, then thing has to be a character. Let's change the code one more time. ###################### seq = file.readline() for ch in seq: ... ####################### Contrast this with: ####################### for line in file.readlines(): ... ####################### This has a *totally* different meaning. The "delta" is a single character in terms of the physical source code, but in terms of what the program means, high impact. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor