importlib: No module named

I have a folder models with a file model.py. I want to import class Model from it and name it NamedModel. If I do this using NamedModel = importlib.import_module("models.model.Model"), I have the followin error: No module named models.model.Model. Although, if I use from models.model import Model, it works. How do I use importlib to import… Read More importlib: No module named

Read nth line of importlib.resources.files without loading whole file in memory

I thought I would be able to use a importlib.resources.files(…).open() object just like a file: from importlib.resources import files with files(‘data’).joinpath(‘graphics.txt’).open() as graphics: for i, line in graphics: if i == 4: print(line) but I get a ValueError: too many values to unpack (expected 2) In this kind of project structure of course: . ├──… Read More Read nth line of importlib.resources.files without loading whole file in memory