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.

查看中文版README请点击:中文文档

⚠️ 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.
  • Cannotc ross 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

python_dream_it_s_mygo-0.1.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

python_dream_it_s_mygo-0.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for python_dream_it_s_mygo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aab704e20ab9825e7af53e3a5589bcf8faebb21a698b661940d7a8ff33e7d0db
MD5 47f68554a4dc687759749cbcd4a037f5
BLAKE2b-256 17ff1e1e5d6282cc822afe541f7129f90700890b8696a4f0e00034a72b9d9b92

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_dream_it_s_mygo-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 python_dream_it_s_mygo-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_dream_it_s_mygo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94c10e8fe682bfc484b91ba0e9b4478f6c00fc6d5d3c1bf8aafdc71207c67ddb
MD5 8a9d3c8c3b9f960f61db094aa5ea5887
BLAKE2b-256 eec007f46992dffb67ef25e570867c5f7039f2856c2c12e3d19094acc4ee4023

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_dream_it_s_mygo-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