Auto implement function stubs
Project description
Magic Stubs
Magic Stubs implements your functions for you.
Demo
https://github.com/user-attachments/assets/f4d0fb4e-3b24-41d6-87ee-ff5931341219
Technology
MagicStubs.py uses a combination of abusing source code encodings, LLM calls, and AST rewriting so you don't have to bother writing code.
Installation
pip install magic_stubs
export OPENAI_API_KEY=...
Or see the live demo on Google Colab.
Usage
Add # coding: magic_stubs
to the top of your python file. Then execute as normal. Magic Stubs will automatically fill in your function definitions where needed.
hello_world.py:
# coding: magic_stubs
def print_hello_world():
pass
print_hello_world()
$ python3 hello_world.py
Hello, World!
Examples
FizzBuzz
$ cat examples/fizzbuzz.py
# coding: magic_stubs
def fizzbuzz(n):
pass
print(' '.join([fizzbuzz(n) for n in range (1, 21)]))
$ python3 examples/fizzbuzz.py
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz
Mandelbrot Set
$ cat examples/mandelbrot.py
# coding: magic_stubs
def get_string_representation_of_mandelbrot_set():
pass
print(get_string_representation_of_mandelbrot_set())
$ python3 examples/mandelbrot.py
***
******
*****
** *************
***********************
* ************************
***************************
****************************
******** ******************************
************ ******************************
******************************************
*************************************************************
******************************************
************ ******************************
******** ******************************
****************************
***************************
* ************************
***********************
** *************
*****
******
***
Attribution
Inspired by and using Tsche's magic_codec.
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
magic_stubs-0.2.2.tar.gz
(4.8 kB
view hashes)
Built Distribution
Close
Hashes for magic_stubs-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04fb00c6116ca66487488cb7dcc0565cb14d538c65406e34f4756ec3fe1b7900 |
|
MD5 | 60816f6954e0cccf2386f426f286ec6d |
|
BLAKE2b-256 | 064703956b053afbcef81bc5384cb1e3bf2a7d7734bc71d2202c2c443a288e73 |