Skip to main content

A Python package for MyGO(Simple Goto)

Project description

MyGO - Interactive Toolset Supporting Multi-directional Yielding Goto Operations

mygo logo

Implementation That Simulates Mind-bending Yet Glorious Operations - A Python package that provides simple label/goto capabilities within the same function using AST transformation.

⚠️ Warning: This library is for research and educational purposes only. Do not use in production environments.

Python Version License: MPL 2.0

Features

  • label("NAME"): Records a jumpable "label line".
  • goto("NAME"): Jumps to the label line on the next line event through a one-time sys.settrace.

This implementation uses AST (Abstract Syntax Tree) transformation to:

  • Collect label locations during the first pass
  • Rewrite goto statements to target line numbers during the second pass
  • Compile the transformed AST back to executable code

Limitations are the same as pdb j:

  • Can only jump within the same function, not across functions/stacks.
  • Cannot跨越 with/try/except/finally/yield/await and other structural boundaries.
  • Target line must have real bytecode (this implementation changes the label line to a constant expression to ensure it can be landed).

Installation

You can install mygo from PyPI:

pip install mygo

Or, install from source:

git clone https://github.com/AndreaFrederica/Python-Dream-It-s-MyGO.git
cd Python-Dream-It-s-MyGO
uv sync

Usage

from mygo import enable_goto, label, goto

@enable_goto
def demo():
    print("A")
    label("L")
    print("B-before")
    goto("L")
    print("C-after")  # This line will never execute

demo()

More examples can be found in the examples/ directory.

Contributing

Issues and Pull Requests are welcome!

License

This project is open source under Mozilla Public License 2.0. See LICENSE file for details.

Contact Author

Email: andreafrederica@outlook.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mygo_goto-0.1.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mygo_goto-0.1.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file mygo_goto-0.1.0.tar.gz.

File metadata

  • Download URL: mygo_goto-0.1.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mygo_goto-0.1.0.tar.gz
Algorithm Hash digest
SHA256 831c64406fa8bede1700d185d4070dce7d13ebee6a153336105b033ad6827ef6
MD5 15fd791388cf590ffe715a60ad922cab
BLAKE2b-256 448c695d68a1330f722649fea53d178dc364d55574120dfdf62a5d7e548676de

See more details on using hashes here.

Provenance

The following attestation bundles were made for mygo_goto-0.1.0.tar.gz:

Publisher: release.yml on AndreaFrederica/Python-Dream-It-s-MyGO

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mygo_goto-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mygo_goto-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mygo_goto-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3172d1721c5c7afab5409c45e3d2a3c96589d8a4b0e8873ef1bc982adc8027dd
MD5 3832f5725c710c63ba96a8b474707499
BLAKE2b-256 ab7e38d80133fbe85a5fc56047ac2bd6af81fed442c29a2908a122a44915983d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mygo_goto-0.1.0-py3-none-any.whl:

Publisher: release.yml on AndreaFrederica/Python-Dream-It-s-MyGO

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page