On 5 May 2013 23:12, Steven D'Aprano <[email protected]> wrote: > > On 06/05/13 12:37, Brian van den Broek wrote:
<snip> >> Try: >> >> def pragmatic_as_if_clear(): >> print '\n' * 100 >> >> which isn't too far off of what clear does in bash. > > Not in the version of bash I am using in an xterm window. (To be precise, > Konsole under KDE 3.) > > If I start a bash session, and then do something "large" like print a file > listing, the prompt ends up right at the bottom of the screen. If I then > call clear, the visible area of the screen is cleared, the prompt ends up at > the top of the screen, but if I scroll back using the scroll bar, I can see > the previous output immediately before the clear command, without 100 blank > lines separating them. terminator 0.93 under openbox 3.5 appears to fill a terminal window height with blank lines. That isn't a hard coded value as above, but that's why I put in the weasel words. Since those words are there, I'll press them into service to cover the further inaccuracy you point out :-) >>>>> A second question is that one person had as the answer to use: >>>>> >>>>> os.system( [ 'clear', 'cls' ][ os.name == 'nt' ] ) >>>>> >>>>> I don't understand this syntax. The writer said that if one >>>>> understands what this is doing, then the method is more generally >>>>> useful. Would someone explain how this works? And hopefully it will >>>>> become apparent to me how this is more generally useful? >>> >> <snip> >> >>> terms when I saw the first pair of brackets, so it did not occur to me >>> to see the second set of brackets as indexing. >>> >>> boB >>> >>> >> >> Steven explained it. I'd point out that wiser snake charmers than I >> discouraged me (some on this list) from using it from the position that >> it >> was too clever. I've done so from time to time anyway; there is a >> momentary >> jolt when reading the code months later. > > > I don't know who they were, I certainly hope they didn't include me. Not so far as I recollect, but it is nearing a decade ago, now. I'll leave my fuzzy memories where they are. FWIW, as indicated, that's a bit of advice I didn't always follow. Best, Brian vdB _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
