On Sun, Apr 26, 2015 at 9:36 AM,  <richm...@gmail.com> wrote:
> The solution ended up being editing the top-level __init__.py:
>
> import awesome
>
> and then *when in a subdirectory*:
>
> import awesome_lib as awesome
>
> and *when in a different top-level file*:
>
> import awesome.
>
> IOW (from what I can tell) I made importing the package the same as importing 
> this one file. When in a subdirectory import via the package, when in a 
> sibling file import the file directly.
>
> This certainly feels odd, and I did find some (likely preferred) different 
> ways I could handle it. My intent was that now I can refer to 
> awesome.util.helper regardless of where I am (outside the package, within 
> different directories, etc). My guess is that doing things like importing 
> 'helper' directly and referring to it as 'helper' (no awesome.util prefix) is 
> the python way of doing things, just didn't ring true with my background.
>

Give "from . import helper" a try; you may find that it works just as
well as "import helper" does, but more explicitly saying that you want
it from the current package. Other than that, I think you have
something that'll work fine.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to