ggwave-python icon indicating copy to clipboard operation
ggwave-python copied to clipboard

suggestion: support with statement for added clarity

Open EmmmaTech opened this issue 1 year ago • 0 comments

support of the with statement can reduce boilerplate code needed to use ggwave and give more clarity. a few builtin utilities in python support with statements, like the file i/o system for example.

so for instance, code like this:

from ggwave_python import GGWave

gg = GGWave()
try:
    ...
finally:
    gg.free()

can be reduced into something more readable:

from ggwave_python import GGWave

gg = GGWave()
with gg:
    ...

# or

with GGWave() as gg:
    ...

all that is needed to implement this are the special methods __enter__ and __exit__.

EmmmaTech avatar Jul 30 '25 17:07 EmmmaTech