Make stuff disappear
pip install gone
The gone
module provides three decorators to manipulate function input and output:
args
: Absorbs all input arguments and calls the decorated function without them.result
: Discards the result of the decorated function.inout
: Absorbs all input arguments and discards the result of the decorated function.
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)
gone
is distributed under the terms of the MIT license.