3 ms·
importlib.resources is an excellent replacement for pkg_resources. with importlib.resources.open_binary('my.package', 'foo.png') as f: ... Avoids the over
by yrro 7y ago
importlib.resources is an excellent replacement for pkg_resources.
with importlib.resources.open_binary('my.package', 'foo.png') as f:
...
Avoids the overhead of importing pkg_resources, and hassle of having to call cleanup_resources before the interpreter shuts down. Backports are available for Python <= 3.6 too!