goto, cls, wait commands

Alan Kennedy alanmk at hotmail.com
Thu Feb 10 12:21:45 EST 2005


[BOOGIEMAN]
> I've just finished reading Python turtorial for non-programmers
> and I haven't found there anything about some usefull commands I used in
> QBasic. First of all, what's Python command equivalent to QBasic's "goto" ?

Oh no! You said the "G" word! That's a dirty word in computer science 
circles, because of the perception that "goto" (there, I said it, ugh!) 
can lead people to structure their code badly, i.e. write bad programs.

Instead, most modern programming languages offer a range of control and 
looping constructs that allow you to code your intention more clearly 
than with goto. Python examples include "while", "for .. in ..", "try .. 
except ..", etc, etc.

So in order to answer your question, you're probably going to have to be 
more specific on what you want "goto" for.

Interestingly, "goto"s are undergoing a bit of renaissance in coding 
circles, but people have felt compelled to call them something 
different: continuations. But you're probably not interested in them. 
And python can't do them anyway.

> Secondly, how do I clear screen (cls) from text and other content ?

That depends on

A: What type of display device you're using
B: What type of interface is being rendered on that display (command 
line, GUI, IDE, etc)
C: Perhaps what operating system you are using.

> And last, how do I put program to wait certain amount of seconds ?
> If I remeber correctly I used to type "Wait 10" and QBasic waits 
> 10 seconds before proceeding to next command.

Ahhhhhh, a simple question! :-)

import time
time.sleep(10.0)

HTH,

-- 
alan kennedy
------------------------------------------------------
email alan:              http://xhaus.com/contact/alan



More information about the Python-list mailing list