this post was submitted on 14 Jul 2023
13 points (93.3% liked)

Python

6360 readers
14 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

๐Ÿ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

๐Ÿ Python project:
๐Ÿ’“ Python Community:
โœจ Python Ecosystem:
๐ŸŒŒ Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
 

I have done plenty of basic scripting for work, but this is my first "real" project, and wanted to see what real python experts think of it and see if there is anything I might be doing horribly wrong lol.

Im deploying documentation automatically here: https://ogs-python.dakotamarshall.net/

And the PyPI package is here: https://pypi.org/project/ogsapi/

I am very much a beginner, and its still very much a work in progress. Let me know if there is anything that could be drastically improved!

you are viewing a single comment's thread
view the rest of the comments
[โ€“] mvee@lemmy.ml 2 points 1 year ago (1 children)

I think what you have is the perfect amount of complexity, and easily extendable. I use callbacks like this all the time in my code, but also my users are part of my team at work so they don't have far for help when the callback API isnt clear :P most of my users dont even know callbacks are a thing.

If your list of supported events gets large or you want to cheaply support future changes to the server, you could pass all event names and data through a handler callback and make users handle multiple event types.

One of the things that makes plain callbacks nice is it's an easy way to let your users decide how they want to integrate with your library. If your callbacks are called from a background thread, it's up to the user to figure out how they want to pass the event to other threads. Async users can use their runtime of choice to submit tasks from a callback.

[โ€“] BoneALisa@lemm.ee 2 points 1 year ago

Awesome, thanks for the feedback!

The callbacks not being widely known about was my concern as well, as I had only heard about them when researching a solution for this, lol. I'll probably stick with my solution, and write a page in the documentation describing what they are and how to use them, to hopefully make it clear.