Skip to main content

A stable and dangerous goto implementation for Python

Project description

nsfw_goto

nsfw_goto is a Python package that allows you to use goto statements in your Python code.

What it really does is simulate a form of "goto" behavior, letting you jump to specific lines of code in your program.

Important disclaimer: This is primarily intended for educational and experimental purposes. Using goto statements in production code is generally discouraged, as it can make code unpredictable and difficult to read and maintain.

Installation

To install nsfw_goto, simply run:

pip install nsfw_goto

Usage

You can use goto to jump to a specific line in your code. Here’s a simple example:

from nsfw_goto import goto

x = 0
x += 1
if x < 3:
    goto(4)

print(x)

In this example, the goto(4) will jump the execution back to line 4, causing the code to repeat itself until the condition x < 3 is no longer met.

The goto functionality even allows jumping between methods. Here’s an example demonstrating how it works across different method calls:

from nsfw_goto import goto

global_value = 0

def foo():
    global global_value
    global_value = 100
    local_value = 200
    goto(14)

def bar():
    print(global_value + local_value)

if global_value == 0:
    foo()

The code jumps from inside the foo() method to inside bar() method, preserving the values of both global_Value and local_value.

Development

If you’d like to contribute to the project, pull requests are very welcome!

Tests for this project are located in the tests folder and use Python’s unittest framework. To run the tests, you can use the following command:

python -m unittest discover tests

This will automatically discover and run all the test cases. Because the goto currently breaks unittest, the unittests run an example code in a separate process and verify the success based on stdout output.

Contribution Guidelines

Feel free to get involved! Fork the repository and clone it to your local machine. Open a pull request with a clear description of what you've added or changed.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

nsfw_goto-0.2.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

nsfw_goto-0.2.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file nsfw_goto-0.2.0.tar.gz.

File metadata

  • Download URL: nsfw_goto-0.2.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for nsfw_goto-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2b3a0477f240e600947fd954e99b771e08afd488ca3bfdeabd7838ba20b91a08
MD5 f72ed3317c0c0c2b7ce421fa48a56eb8
BLAKE2b-256 baa902eb1bda05324e44b522b6fbc25b8a0fb6a6ced8eaf83cd259daf5c1da9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for nsfw_goto-0.2.0.tar.gz:

Publisher: publish.yml on naslundx/nsfw_goto

Attestations:

File details

Details for the file nsfw_goto-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: nsfw_goto-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for nsfw_goto-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0afc054ad48b1c1acb3459b6850372372878f81ad4016195e646230d21cf95e4
MD5 136edf3697726b6706ad01d04496de47
BLAKE2b-256 d60d13c93c0bfdc5c423aa67e26c3aa1a4203f3006268794698c42512fdf5b02

See more details on using hashes here.

Provenance

The following attestation bundles were made for nsfw_goto-0.2.0-py3-none-any.whl:

Publisher: publish.yml on naslundx/nsfw_goto

Attestations:

Supported by

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