On 5 May 2013 22:10, boB Stepp <[email protected]> wrote:
> On Sun, May 5, 2013 at 7:54 PM, Steven D'Aprano <[email protected]>
> wrote:
>
<snip>
> >
> >> So my main question is there a truly clean, cross-platform solution to
> >> the clear screen dilemma? If my online searching is accurate, then the
> >> answer appears to be no, unless one wants to print many blank lines.
> >
> >
> > Your googling is accurate. There is no clean, cross-platform solution,
> not
> > even for the "main three" (Linux/Unix, Windows, Mac), let alone minority
> and
> > legacy platforms, other implementations, etc.
> >
>
>
> So it appears that the only way to cover the various possibilities is
> to query for the platform being used and then apply the correct
> statement for that platform. And it still would not work for the point
> noted above. Could be a lot of effort for little gain!
>
>
Try:
def pragmatic_as_if_clear():
print '\n' * 100
which isn't too far off of what clear does in bash.
> >
> >> 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.
HTH,
Brian vdB
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor