Python Forum
right now a goto would be useable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
right now a goto would be useable
#8
Here is an ersatz of downward goto
from collections import defaultdict

goto = label = defaultdict(
    lambda: type('Goto', (Exception,), {})).__getitem__

def main(x):
    try:
        ...
        if x == 3:
            raise goto('spam')
        ...
    except label('spam'):
        print('Goto worked!')

if __name__ == '__main__':
    main(3)
Reply


Messages In This Thread
right now a goto would be useable - by Skaperen - Jul-09-2020, 04:24 AM
RE: right now a goto would be useable - by DeaD_EyE - Jul-09-2020, 07:49 AM
RE: right now a goto would be useable - by ndc85430 - Jul-09-2020, 12:02 PM
RE: right now a goto would be useable - by Skaperen - Jul-10-2020, 12:49 AM
RE: right now a goto would be useable - by Skaperen - Jul-10-2020, 06:27 PM
RE: right now a goto would be useable - by Gribouillis - Jul-10-2020, 07:08 PM
RE: right now a goto would be useable - by voidptr - Jul-25-2020, 05:23 AM
RE: right now a goto would be useable - by Skaperen - Jul-26-2020, 12:25 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020