ggwave-python
ggwave-python copied to clipboard
suggestion: support with statement for added clarity
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__.