Code Monkey home page Code Monkey logo

gone's Introduction

gone

Make stuff disappear

PyPI - Version PyPI - Python Version


Table of Contents

Installation

pip install gone

Usage

The gone module provides three decorators to manipulate function input and output:

  1. args: Absorbs all input arguments and calls the decorated function without them.
  2. result: Discards the result of the decorated function.
  3. inout: Absorbs all input arguments and discards the result of the decorated function.

Usage Example

import gone

## as a decorator:

@gone.args
def greet():
    return "Hello World"

greet(1, 2, key=3)  # Result: Hello, world!

@gone.result
def add(a, b):
    return a + b

print(add(1, 2))  # Output: None


@gone.inout
def display_message():
    print("This will print, but inputs and outputs are ignored.")
    return "ignored"

display_message("ignored input")  # Output: This will print, but inputs and outputs are ignored; Returns: None


## or as a function:

import os, signal

def main():
    def sig_handler():
        print("Runs without the default 'signal, frame' arguments!")
        return "ignored"

    # listen to signal:
    signal.signal(signal.SIGFPE, gone.inout(sig_handler))
    # just `sigint_handler` would crash because it's getting unexpected args

    # send signal:
    os.kill(os.getpid(), signal.SIGFPE)

License

gone is distributed under the terms of the MIT license.

gone's People

Contributors

robinvandernoord avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.