Problem
no problem, but I think we are handling this task differently in other packages so let's revisit and see if there is a standard way to do it. In general, I would rather not have it in the __init__.py file. I am not sure why, but I never really like importing things from there as a I don't fully understand the behavior.
Proposed solution
Right now it has to be there because files(__name) returns the package name when it is called from the init for some reason, and then this is returned as a context manager. I think in other packages in diffpy where we are trying to do the same thing, we do something like find the path of current file as a Pathlib object, then recurse around using .parent and so on to get the path we are after and then pass that to a function that opens the file. This just seems more explicit and less magical to me.
Problem
no problem, but I think we are handling this task differently in other packages so let's revisit and see if there is a standard way to do it. In general, I would rather not have it in the
__init__.pyfile. I am not sure why, but I never really like importing things from there as a I don't fully understand the behavior.Proposed solution
Right now it has to be there because
files(__name)returns the package name when it is called from the init for some reason, and then this is returned as a context manager. I think in other packages in diffpy where we are trying to do the same thing, we do something like find the path of current file as aPathlibobject, then recurse around using.parentand so on to get the path we are after and then pass that to a function that opens the file. This just seems more explicit and less magical to me.