Sorry, my bad, dumb noob error:

with 
from pkg.utils import * in script.py it works fine.



Am Montag, 8. Oktober 2018 00:40:43 UTC+2 schrieb lueromat:
>
> Hi all,
>
> I have written a python package with the following structure:
>
> pkg/
>     __init__.py
>     script.py
>     utils.py
>
> During development, I import the folders from my local repo to add new 
> code - not from site-packages. My problem is that after the local import, 
> the namespace from utils (containing helper functions) is not recognized in 
> script (containing core functionality, using helper functions). Therefore 
> spyder creates "undefined name" flags in my scripts, which is not helpful. 
> However, when I put import utils at the top of the script, it cannot get 
> imported and I get the error "No module named 'utils'. 
>
> Is there a way to tell spyder where these functions are defined without 
> breaking the package load? 
>
>
>
> My init file contains:
>
> import pkgutil
> import inspect
>
>
> for loader, name, is_pkg in pkgutil.walk_packages(__path__):
>     module = loader.find_module(name).load_module(name)
>
>
>     for name, value in inspect.getmembers(module):
>         if name.startswith('__'):
>             continue
>
>
>         globals()[name] = value
>         __all__.append(name)
>
> from pgk import script1, utils
>         
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

Reply via email to