Metadata-Version: 2.4
Name: Python-Dream-It-s-MyGO
Version: 0.1.0
Summary: A Python package for MyGO(Simple Goto)
Project-URL: Homepage, https://github.com/AndreaFrederica/Python-Dream-It-s-MyGO
Project-URL: Repository, https://github.com/AndreaFrederica/Python-Dream-It-s-MyGO.git
Project-URL: Issues, https://github.com/AndreaFrederica/Python-Dream-It-s-MyGO/issues
Author-email: AndreaFrederica <andreafrederica@outlook.com>
License: MPL-2.0
License-File: LICENSE
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.12
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == 'dev'
Requires-Dist: pip>=25.2; extra == 'dev'
Requires-Dist: setuptools>=80.9.0; extra == 'dev'
Requires-Dist: twine>=6.2.0; extra == 'dev'
Requires-Dist: wheel>=0.45.1; extra == 'dev'
Description-Content-Type: text/markdown

# MyGO - **I**nteractive **T**oolset **S**upporting **M**ulti-directional **Y**ielding **G**oto **O**perations

<p align="center">
  <img src="https://raw.githubusercontent.com/AndreaFrederica/Python-Dream-It-s-MyGO/4fa21421a356aa2f8c3108dd0f4e6ce1486cf410/logo.svg" alt="mygo logo" width="200"/>
</p>

**I**mplementation **T**hat **S**imulates **M**ind-bending **Y**et **G**lorious **O**perations - A Python package that provides simple label/goto capabilities within the same function using AST transformation.

查看中文版README请点击：[中文文档](https://github.com/AndreaFrederica/Python-Dream-It-s-MyGO/blob/master/README_zh_CN.md)

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

[![Python Version](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
[![License: MPL 2.0](https://img.shields.io/badge/license-MPL_2.0-brightgreen.svg)](LICENSE)

## 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:

```bash
pip install mygo
```

Or, install from source:

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

## Usage

```python
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](LICENSE) file for details.

## Contact Author

Email: andreafrederica@outlook.com