1

I am working in ProjectEuler problems. Lots of the problem share common algorithms such as prime factorization, thus it makes sense to build library scripts that store these algorithms.

As of now I have something like the following structure

ProjectEuler/
    001/
        euler001.py
    002/
        euler002.py
        supporting.txt
    utils/
        primes.py
        combinatorics.py

I want to be able from any problem file (e.g. euler002.py import functions from files in utils (e.g primes.py).

How should I go about this?

  • Here is about relative import: [How to do relative imports in Python?](http://stackoverflow.com/questions/72852/how-to-do-relative-imports-in-python) – Vadim Shkaberda May 08 '16 at 06:54
  • Woah, the duplicate post solutions look quite confusing. I would like something related to package structure, like an import, modifying my sys.path or PYTHONPATH seems like overkill. Is this some kind of antipattern? – Jose Javier Gonzalez Ortiz May 08 '16 at 14:58

0 Answers0