cdjc / goto

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

goto

An implementation of goto for Python 3.

Copy goto.py where your code can import it.

Usage:

from goto import goto

@goto
def matrix_find(matrix, n):
    for rectangle in matrix:
        for line in rectangle:
            for value in line:
                if value == n:
                    rval = "found"
                    goto .found
    rval = "not found"
    label .found
    # ... other code here ...
    return rval

print(matrix_find([[[1,2]],[[3,4]]], 3))   # "found"
print(matrix_find([[[1,2]],[[3,4]]], 99))  # "not found"

About

License:MIT License


Languages

Language:Python 55.1%Language:TeX 35.0%Language:Typst 8.6%Language:Makefile 1.4%