[code-quality] Pylint and sys path

Florian Bruhin me at the-compiler.org
Thu Mar 12 22:08:04 CET 2015


* Dani Hodovic <danihgit at gmail.com> [2015-03-12 21:51:50 +0100]:
> I have a very large project with deeply nested hierarchies. To find the
> root directory I use a source root walker and append the root directory to
> sys.path. This way, I can easily import things in the project relative to
> the root directory.

I don't know how to teach pylint to understand this - but if I
understood correctly, shouldn't python packages to that anyways?
e.g. if you have a tree like this:

myproject/
    __init__.py
    utils/
        __init__.py
        foo.py
        bar.py
    modules/
        __init__.py
        eggs.py
        bacon.py
        spam.py

And start your project correctly via `python -m myproject`, you should
be able to do something like `from myproject.utils.foo import fish` in
e.g. myproject/modules/eggs.py just fine.

If that is what you're attempting, I recommend reading
http://bit.ly/pypackages.

If not and I misunderstood something, sorry! :)

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/code-quality/attachments/20150312/1a24430e/attachment.sig>


More information about the code-quality mailing list