Skip to main content

Add your description here

Project description

Top Hat

Do you know how magicians could pull stuff out of an apparently empty top hat?

I only recently discovered how that worked, and apparently it was dunder methods all along! Who would have thought!

So I decided to implement something similar in Python: you can import any method whatsoever from this magical magic_top_hat, even if the module itself seems empty!

import magic_top_hat

dir(magic_top_hat) # returns []

BUT! With sleight of hand you can actually import anything you want out of the magic_top_hat:

from magic_top_hat import get_day_out_of_datetime
from datetime import datetime

def get_today_day() -> str: 
    today = datetime.now()
    day = get_day_out_of_datetime(today)
    return day # this will return the day name

and a function will be generated that satisfies your every need*!

Do you need to know how the function generated your result? No, right? Implementation is just a detail for the code monkeys! If you really have no trust in this (as you should), you can set the environmental variable I_DONT_TRUST_ROBOTS to have each implementation printed out.

*satisfaction not guaranteed. You will need to set a OPENAI_API_KEY env parameter for this to work. And even then, it might not work.

How

Well, I simply send the caller code to OpenAI and ask ChatGPT to generate a function that will fulfill the request, given the context in which it was called, the name it was given and the parameters it received.

So the results may vary from abysmal to groteque.

Why

It was really fun to try and build something like this, also I had a couple of hours to kill before sleep. Also, I can honestly say that this is AI powered!

Examples

Look at scripts/example.py for a couple of simple examples!

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_top_hat-0.1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

magic_top_hat-0.1.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file magic_top_hat-0.1.0.tar.gz.

File metadata

  • Download URL: magic_top_hat-0.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for magic_top_hat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 88b3040d879769e3b4a5d921f3b6a170cddf87cd08a0164feece3e0ef2b3d42d
MD5 e477e084ec840ac30a75b0b5ebacb38c
BLAKE2b-256 67e17768616e51fdac476e2c6d322f773f61c492f4620287765ce6abaacce144

See more details on using hashes here.

File details

Details for the file magic_top_hat-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: magic_top_hat-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for magic_top_hat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1649f5cbe7dea9171798da6fb1981175b383af0034462277a11a84a3d81779b7
MD5 a3a963f99a4732f36d98e57fbde96956
BLAKE2b-256 0de65c47a5e339ca0ba477dfcba325dc037449b63aca9b86bb27790028fedd09

See more details on using hashes here.

Supported by

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