I guess it depends if you want to expose those setup and teardown
functions to the users of your Python wrapper or not.
If not, you can still choose if you want to initialize your library at
import time (and clean up when the interpreter exits) or if you want
to create a class (which could be used as a context manager) or you
can wrap every single function call with a setup/teardown.
As an example (but I don't know if it's a good one), you can have a
look at my "sounddevice" module:
https://github.com/spatialaudio/python-sounddevice/blob/master/sounddevice.py
It initializes the underlying C library at import time and uses the
"atexit" module to register an exit handler.
Another example (still don't know if a good one) would be my "jack"
module:
https://github.com/spatialaudio/jackclient-python/blob/master/jack.py
There is a "Client" class which does some initialization in __init__()
and it has a close() function for cleanup. The class can also be used
as a context manager.
cheers,
Matthias
> Cheers,
> Ghis