https://github.com/xpodev/pyuck
https://github.com/xpodev/pyuck
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/xpodev/pyuck
- Owner: xpodev
- License: mit
- Created: 2024-11-16T16:47:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-16T17:23:22.000Z (over 1 year ago)
- Last Synced: 2025-10-11T01:32:09.289Z (9 months ago)
- Language: Python
- Size: 8.79 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Yuck!
`Yuck!` is a library that is helpful when you need to create a singleton instance of a function.
Just decorate the function you want to singletonize, call it once with setup arguments and subsequent calls
will use the already setup function call.
## Example
```py
from yuck import yuck
@yuck
def db(connection_string: str):
connection = connect(connection_string)
query = yield
while True:
query = yield connection.execute(query)
# Initial setup
db_instance = db("sqlite:///:memory:")
# Use the singleton instance
result = db_instance.send("SELECT * FROM users")
print(result)
```
> NOTE: I'm not entirely sure this really works but I'm too lazy to even check :D.