A Python package for MyGO(Simple Goto)
Project description
MyGO - Interactive Toolset Supporting Multi-directional Yielding Goto Operations
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.
Features
label("NAME"): Records a jumpable "label line".goto("NAME"): Jumps to the label line on the next line event through a one-timesys.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aab704e20ab9825e7af53e3a5589bcf8faebb21a698b661940d7a8ff33e7d0db
|
|
| MD5 |
47f68554a4dc687759749cbcd4a037f5
|
|
| BLAKE2b-256 |
17ff1e1e5d6282cc822afe541f7129f90700890b8696a4f0e00034a72b9d9b92
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_dream_it_s_mygo-0.1.0.tar.gz -
Subject digest:
aab704e20ab9825e7af53e3a5589bcf8faebb21a698b661940d7a8ff33e7d0db - Sigstore transparency entry: 600993247
- Sigstore integration time:
-
Permalink:
AndreaFrederica/Python-Dream-It-s-MyGO@470536fe5d039dd287183fa9fdd5ab91b9b8d3b2 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/AndreaFrederica
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@470536fe5d039dd287183fa9fdd5ab91b9b8d3b2 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file python_dream_it_s_mygo-0.1.0-py3-none-any.whl.
File metadata
- Download URL: python_dream_it_s_mygo-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94c10e8fe682bfc484b91ba0e9b4478f6c00fc6d5d3c1bf8aafdc71207c67ddb
|
|
| MD5 |
8a9d3c8c3b9f960f61db094aa5ea5887
|
|
| BLAKE2b-256 |
eec007f46992dffb67ef25e570867c5f7039f2856c2c12e3d19094acc4ee4023
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_dream_it_s_mygo-0.1.0-py3-none-any.whl -
Subject digest:
94c10e8fe682bfc484b91ba0e9b4478f6c00fc6d5d3c1bf8aafdc71207c67ddb - Sigstore transparency entry: 600993248
- Sigstore integration time:
-
Permalink:
AndreaFrederica/Python-Dream-It-s-MyGO@470536fe5d039dd287183fa9fdd5ab91b9b8d3b2 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/AndreaFrederica
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@470536fe5d039dd287183fa9fdd5ab91b9b8d3b2 -
Trigger Event:
workflow_dispatch
-
Statement type: