473,383 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Goto


How does one effect a goto in python? I only want to use it for debug.
I dasn't slap an "if" clause around the portion to dummy out, the
indentation police will nab me.

Thanx,

jh

Jun 13 '07 #1
7 1523
How does one effect a goto in python? I only want to use it for debug.
I dasn't slap an "if" clause around the portion to dummy out, the
indentation police will nab me.

http://entrian.com/goto/
Jun 13 '07 #2
On Wed, 2007-06-13 at 12:20 -0700, HMS Surprise wrote:
How does one effect a goto in python?
One doesn't.
I only want to use it for debug.
I dasn't slap an "if" clause around the portion to dummy out, the
indentation police will nab me.
If you want to disable a code block without indenting it into an "if
False:" block, use triple quotes, either ''' or """, to turn it into a
long string.

HTH,

--
Carsten Haese
http://informixdb.sourceforge.net
Jun 13 '07 #3
Thanks folks!

jh

Jun 13 '07 #4
"HMS Surprise" <john@d...t.comwrote:

>
How does one effect a goto in python? I only want to use it for debug.
I dasn't slap an "if" clause around the portion to dummy out, the
indentation police will nab me.
I use a global boolean called trace:

if trace:
do debug stuff

But to try to answer your question:

There are two gotos in standard Python.
They are spelled:

"continue" and "break"

The first jumps to the start of a loop, and the last to after the end of one.

Anything more fancy is "Verboten" - except, that, if you ask nicely,
John Machin might explain his comefrom construct.

And maybe I will understand it this time around...

- Hendrik
Jun 14 '07 #5
Daniel Nogradi wrote:
>How does one effect a goto in python? I only want to use it for debug.
I dasn't slap an "if" clause around the portion to dummy out, the
indentation police will nab me.


http://entrian.com/goto/
LOL!! * major flashback to horrible BASIC programs from the eighties *

Back then I took a course in structured BASIC programming (now there is
a contradiction in terms) and the instructor warned about goto time and
time again. But his biggest mistake was to tell us that if we had to use
goto at least we should explain it in a comment. So we would turn in
programs with sections like:

100 IF S$="YES" THEN GOTO 150
110 REM Go to line 150 if S$ is Yes
Tina
Jun 17 '07 #6
On Jun 14, 4:32 pm, "Hendrik van Rooyen" <m...@microcorp.co.zawrote:
[snip]
>
Anything more fancy is "Verboten" - except, that, if you ask nicely,
John Machin might explain his comefrom construct.

And maybe I will understand it this time around...
Hendrik, if you google for 'comefrom' in this newsgroup, you will get
several threads. However if you google for 'Machin comefrom' the only
hit is the above posting. You must be confusing me with somebody else.
Cheers,
John

Jun 17 '07 #7
On 2007-06-17, Tina I <ti*****@bestemselv.comwrote:
Back then I took a course in structured BASIC programming (now
there is a contradiction in terms) and the instructor warned
about goto time and time again. But his biggest mistake was to
tell us that if we had to use goto at least we should explain
it in a comment. So we would turn in programs with sections
like:

100 IF S$="YES" THEN GOTO 150
110 REM Go to line 150 if S$ is Yes
Once I learned GOSUB (in Commodore BASIC) I used it instead of
GOTO all the time. I used it for functions long before I learned
about functions in Programming 101.

100 NAME$="TED"
110 AGE=40
120 GOSUB 1000
1000 PRINT NAME$, " IS ", AGE, " YEAR(S) OLD."
1010 RETURN

Named functions are so much nicer than numbered ones.

--
Neil Cerutti
Jun 17 '07 #8

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

Similar topics

30
by: Hayri ERDENER | last post by:
hi, what is the equivalent of C languages' goto statement in python? best regards
51
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...
37
by: Tim Marshall | last post by:
From http://www.mvps.org/access/tencommandments.htm 9th item: Thou shalt not use "SendKeys", "Smart Codes" or "GoTo" (unless the GoTo be part of an OnError process) for these will lead you...
52
by: Rick | last post by:
Hi, For portability, can an issue arise if we use while(1) for an infinite loop in C? If so, should we then use for(;;)? Thanks, Rick
45
by: Debashish Chakravarty | last post by:
K&R pg.66 describes two situations when using goto makes sense. Has anyone here come across situations where using goto provided the most elegant solution. --...
77
by: M.B | last post by:
Guys, Need some of your opinion on an oft beaten track We have an option of using "goto" in C language, but most testbooks (even K&R) advice against use of it. My personal experience was that...
34
by: electrician | last post by:
Perl has it, Basic has it, Fortran has it. What is so difficult about creating a goto command for JavaScript. Just set up a label and say go to it.
3
by: electrician | last post by:
Yes, no GOTO. This is a major blunder on part of the creators of these tools. GOTO gives the programmer the absolute control over the program. Yes, no matter what, a GOTO sends the program to...
17
by: SoftEast | last post by:
Hi Buddies, I have read a lot of stuffs regarding not using GOTO statements to opt a good programming style http://david.tribble.com/text/goto.html]. Can anybody give a particular lines of code...
59
by: raashid bhatt | last post by:
why are GOTO's not used they just a simple JMP instructions what's bad about them
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.