473,761 Members | 9,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

goto, cls, wait commands

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" ?
Secondly, how do I clear screen (cls) from text and other content ?
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.
Jul 18 '05 #1
25 4645
BOOGIEMAN a écrit :
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" ? I had a professor that told me that using goto in prog is that there is
a mistake in the algorythm.
If I remember, I think there is no goto instruction in python !
Secondly, how do I clear screen (cls) from text and other content ? I don't understand well what you exactly want to do. Can you explain
more please.
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.

import time
time.sleep(10)
Jul 18 '05 #2
BOOGIEMAN wrote:
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" ?
There isn't one. Why do you think you need this?
Secondly, how do I clear screen (cls) from text and other
content ?
That depends on your computer, and how you are running your program.
One way which *might* work is:

import os
os.system("cls" )
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.


import time
time.sleep(10)
Jul 18 '05 #3
On Thu, 10 Feb 2005 16:59:04 +0100, rumours say that BOOGIEMAN
<BO*********@YA HOO.COM> might have written:

Best advice: try to forget QBasic, and try again reading the tutorial. That, if
your post is serious. If it isn't, keep reading my reply :)
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" ?
goto for python:

http://entrian.com/goto/index.html

Please ignore the line in bold red.
Secondly, how do I clear screen (cls) from text and other content ?
Python clears after itself, so you don't need to. If you insist though,

..>> import os
..>> os.system('cls' )

That on a windows "console".

If on IDLE, try closing the window and reopening it.
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.


(A serious answer for a change) Waiting is time related. So import time and
call the time.sleep function.

Try entering help at a Python prompt.
--
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
Jul 18 '05 #4
On 2005-02-10, BOOGIEMAN <BO*********@YA HOO.COM> wrote:
First of all, what's Python command equivalent to QBasic's "goto" ?
There isn't one.

One defines functions and calls them. One uses for and while
loops. One uses list comprehensions. One uses if/elif/else.
Secondly, how do I clear screen (cls) from text and other content ?
That depends on the host system. Under Unix, you can do
os.system('clea r'). Or you can use ncurses. Or you can use
os.system to run the 'tput' command with appropriate parameters
-- see the tput man page.

There's probably some way to do it in Windows as well, but I
don't do windows.
And last, how do I put program to wait certain amount of
seconds ?


time.sleep(1) will wait for 1 second.
time.sleep(5.5) will wait for 5.5 seconds.

--
Grant Edwards grante Yow! Yow! I like my new
at DENTIST...
visi.com
Jul 18 '05 #5
[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
Jul 18 '05 #6
Duncan Booth a écrit :
BOOGIEMAN wrote:

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


That depends on your computer, and how you are running your program.
One way which *might* work is:

import os
os.system("cls" )


*might* work... !-)
bruno@bibi modulix $ cls
-bash: cls: command not found

Bad luck ! didn't work !-)

Bruno
Jul 18 '05 #7
Grant Edwards a écrit :
On 2005-02-10, BOOGIEMAN <BO*********@YA HOO.COM> wrote:

First of all, what's Python command equivalent to QBasic's "goto" ?

There isn't one.

One defines functions and calls them. One uses for and while
loops. One uses list comprehensions. One uses if/elif/else.


and even sometimes break, continue, and return !-)
Jul 18 '05 #8
On 2005-02-10, Bruno Desthuilliers <bd************ *****@free.quel quepart.fr> wrote:
Grant Edwards a écrit :
On 2005-02-10, BOOGIEMAN <BO*********@YA HOO.COM> wrote:

First of all, what's Python command equivalent to QBasic's "goto" ?

There isn't one.

One defines functions and calls them. One uses for and while
loops. One uses list comprehensions. One uses if/elif/else.


and even sometimes break, continue, and return !-)


I forgot to mention try/except. When I do use goto in C
programming it's almost always to impliment what would have
been a try/except block in Python.

--
Grant Edwards grante Yow! ... the MYSTERIANS
at are in here with my
visi.com CORDUROY SOAP DISH!!
Jul 18 '05 #9
Bruno Desthuilliers wrote:
Duncan Booth a écrit :
BOOGIEMAN wrote:
Secondly, how do I clear screen (cls) from text and other
content ?


That depends on your computer, and how you are running your program.
One way which *might* work is:

import os
os.system("cls" )


*might* work... !-)
bruno@bibi modulix $ cls
-bash: cls: command not found

Bad luck ! didn't work !-)


Works for me! But then again...

kairos:ug> cat cls
#! /usr/local/bin/python
print "\xc",

/ug 8-)
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1575
by: Philip Smith | last post by:
I've read with interest the continuing debate about 'lambda' and its place in Python. Just to say that personally I think its an elegant and useful construct for many types of programming task (particularly number theory/artificial intelligence/genetic algorithms) I can't think why anyone would be proposing to do away with it. Sometimes an anonymous function is just what you need and surely it just reflects the python philosophy of...
3
12797
by: Tim Stokes | last post by:
Hello all, Is it possible to make an asp script 'wait' inbetween commands? A quick example (but not what I've got in mind): Response.write ("Please wait. Validating password...") Response.redirect ("done.asp")
51
13387
by: WindAndWaves | last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one of those NEVER USE. I can understand that it may lead to confusing code, but I often use it like this: is this wrong????? Function x select case z
24
3648
by: sureshjayaram | last post by:
In some functions where i need to return multiple error codes at multiple places, I use multiple return statements. Say for ex. if (Found == 1) { if (val == -1) return error1; } else { if (val2 == -1)
6
3651
by: eBob.com | last post by:
How do you make a loop iterate early without using a GoTo? (I guess I've done too much structured programming and I really don't like using GoTos.) Here's my code ... For Each Thing As OFI In FileInfo If Thing.Displayed <> True Then GoTo Iterate 'skip this entry; try next one End If
5
11366
by: BF | last post by:
Hi, I have a problem: I am writing an update script for a database and want to check for the version and Goto the wright update script. So I read the version from a table and if it match I want to "Goto Versionxxx" Where Versionxxx: is set in the script with the right update script.
3
3276
by: memyselfandmiah | last post by:
I am in a cpp class, but i am messing around the program on my own, and I am looking for some commands. or at least a place that i can go to find commands that i want. There are 2 questions that I currently have. When i started with coding (way back on QBASIC) there were 2 commands that it seems like should be somewhat universal. one was a wait function. IE, in a loop function a command that makes the program wait for time N before it...
19
15893
by: David Given | last post by:
I have a situation where I need to use GOTO in a Javascript program. No, I can't use break or continue. Yes, I really do know what I'm doing. What I've got is a huge mass of automatically generated code that contains thousands of clauses like this: label1: ...do something... if (condition) goto label3;
59
5062
by: raashid bhatt | last post by:
why are GOTO's not used they just a simple JMP instructions what's bad about them
0
9988
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9923
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8813
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.