command line reports
Peter Hansen
peter at engcorp.com
Thu Aug 11 22:04:12 EDT 2005
Darren Dale wrote:
> Thanks, I didnt realize that \r is different from \n.
\r has is a byte with value 13, which is the Carriage Return (CR)
control character in ASCII. \n has value 10 and is the Line Feed (LF)
character. CR is named after the old teletypewriter operation involving
moving the "carriage" back to one edge to restart typing text. It
wasn't very useful without also moving to a new line (unless you wanted
to cut your paper by repeatedly printing a line of hyphens), which is
what LF was used for -- like rotating the platen (I think that's the
word) on a typewriter up one line. Hitting the arm on a typewriter is
like a CR plus a LF together, and this is immortalized in the CR/LF
combination required still under Microsoft's most advanced operating
systems, long after it's no longer necessary to have the two distinct
characters. (<sigh>)
Most operating systems have adopted the combined behaviour (go to start
of line, move down one line) together under the LF character, since
ASCII doesn't have a single "new line" character (though VT or Vertical
Tab has been proposed for that since it has no other practical use these
days). The CR character still generally does the "go to start of line"
operation when used in the console, so it's pretty handy to "overwrite
the previous line" as you wanted to. In rare situations, such as
terminal software like Hyperterm, LF doesn't necessarily take you back
to the start of a line but merely moves you down a single line at the
same column position, much like its original/intended behaviour.
-waxing-historically-and-97-percent-accurately y'rs,
Peter
More information about the Python-list
mailing list