Re: Good python equivalent to C goto

2008-08-18 Thread Chuck Rhode
On Sun, 17 Aug 2008 09:08:35 -0500, Grant Edwards wrote: In Python one uses try/raise/except. At the risk of introducing an anachronism and in deference to Mr. ElementTree Lundh, I now invoke Godwin's Law (1990): Isn't *try/except* kinda sorta like the musty, old *come from* construct proposed

Re: Good python equivalent to C goto

2008-08-18 Thread Robin Becker
Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next; if (condition3) goto next; stmt1; stmt2; next: stmt3; stmt4; }

RE: Good python equivalent to C goto

2008-08-18 Thread Reedick, Andrew
-Original Message- From: [EMAIL PROTECTED] [mailto:python- [EMAIL PROTECTED] On Behalf Of Kurien Mathew Sent: Saturday, August 16, 2008 5:21 PM To: python-list@python.org Subject: Good python equivalent to C goto Hello, Any suggestions on a good python equivalent

Re: Good python equivalent to C goto

2008-08-18 Thread Paul McGuire
On Aug 17, 1:09 pm, Matthew Fitzgibbons [EMAIL PROTECTED] wrote: Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) {     if (condition1)         goto next;     if (condition2)         goto next;     if

Re: Good python equivalent to C goto

2008-08-18 Thread Matthew Fitzgibbons
Paul McGuire wrote: On Aug 17, 1:09 pm, Matthew Fitzgibbons [EMAIL PROTECTED] wrote: Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next; if

Re: Good python equivalent to C goto

2008-08-17 Thread Carl Banks
On Aug 17, 12:35 am, Michael Torrie [EMAIL PROTECTED] wrote: However it's not necessary in python to do any of this, since you can define nested functions that have access to the parent scope.  Anytime you need to clean up, just call the nested cleanup function and then return. That is

Re: Good python equivalent to C goto

2008-08-17 Thread info
as an oldtimer, I know that in complex code the goto statement is still the easiest to code and understand. I propose this solution using exception. The string exception is deprecated but is simpler for this example. # DeprecationWarning: raising a string exception is deprecated def

Re: Good python equivalent to C goto

2008-08-17 Thread Marc 'BlackJack' Rintsch
On Sat, 16 Aug 2008 23:20:52 +0200, Kurien Mathew wrote: Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next; if (condition3) goto

Re: Good python equivalent to C goto

2008-08-17 Thread Grant Edwards
On 2008-08-16, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Sat, 16 Aug 2008 23:20:52 +0200, Kurien Mathew [EMAIL PROTECTED] declaimed the following in comp.lang.python: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if

Re: Good python equivalent to C goto

2008-08-17 Thread Matthew Fitzgibbons
Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next; if (condition3) goto next; stmt1; stmt2; next: stmt3; stmt4; }

Re: Good python equivalent to C goto

2008-08-17 Thread info
On Aug 17, 8:09 pm, Matthew Fitzgibbons [EMAIL PROTECTED] wrote: Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) {     if (condition1)         goto next;     if (condition2)         goto next;     if

Re: Good python equivalent to C goto

2008-08-17 Thread Matthew Fitzgibbons
[EMAIL PROTECTED] wrote: On Aug 17, 8:09 pm, Matthew Fitzgibbons [EMAIL PROTECTED] wrote: Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next;

Re: Good python equivalent to C goto

2008-08-17 Thread Paul Hankin
On Aug 16, 11:20 pm, Kurien Mathew [EMAIL PROTECTED] wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) {         if (condition1)                 goto next;         if (condition2)                 goto next;         if (condition3)

Re: Good python equivalent to C goto

2008-08-17 Thread info
On Aug 17, 9:23 pm, Matthew Fitzgibbons [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Aug 17, 8:09 pm, Matthew Fitzgibbons [EMAIL PROTECTED] wrote: Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) {     if

Re: Good python equivalent to C goto

2008-08-17 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: The goto code is the simpler way to do it. We are not talking about simple if-else, but let say 20 if-else. Many nested if-else are more difficult to understand and do not fit better the semantics. let's see... $ cd ~/svn/python25 $ grep goto */*.c | wc 2107

Re: Good python equivalent to C goto

2008-08-17 Thread Matthew Fitzgibbons
as mentioned 'in complex code the goto statement is still the easiest to code and understand'. The examples are very small and do not require that at all. I agree it's ugly. Just to show a way to do it. A very few functions where I use goto in C or C# are a few hundred lines of code, difficult

Good python equivalent to C goto

2008-08-16 Thread Kurien Mathew
Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next; if (condition3) goto next; stmt1; stmt2; next:

Re: Good python equivalent to C goto

2008-08-16 Thread Jean-Paul Calderone
On Sat, 16 Aug 2008 23:20:52 +0200, Kurien Mathew [EMAIL PROTECTED] wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next; if

Re: Good python equivalent to C goto

2008-08-16 Thread Fredrik Lundh
Kurien Mathew wrote: Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next; if (condition3) goto next; stmt1; stmt2; next: stmt3; stmt4; } seems

Re: Good python equivalent to C goto

2008-08-16 Thread Thomas Mlynarczyk
Kurien Mathew schrieb: Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next; if (condition3) goto next; stmt1; stmt2; next: stmt3; stmt4; } while

Re: Good python equivalent to C goto

2008-08-16 Thread Christian Heimes
Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: There are various ways to write your example in Python. For example while loopCondition: condition = 1 while condition: if condition1: break if condition2:

Re: Good python equivalent to C goto

2008-08-16 Thread Michael Torrie
Dennis Lee Bieber wrote: Nasty code even for C... I've never used goto in C... Options: convert the statements of next into a function, and put in an else clause... I think the parent post's pseudocode example was too simple to show the real benefits and use cases of goto in C.

Re: Good python equivalent to C goto

2008-08-16 Thread Michael Torrie
Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next; if (condition3) goto next; stmt1;

Re: Good python equivalent to C goto

2008-08-16 Thread Michael Torrie
Michael Torrie wrote: I think the most direct translation would be this: Nevermind I forgot about the while loop and continuing on after it. Guess the function doesn't quite fit this use case after all. -- http://mail.python.org/mailman/listinfo/python-list