2

given this folder structure:

search/
      __init__.py
      blogs.py
database/
      __init__
      tags.py

if I'm working at tags.py, how can I import a class called crawler inside blogs.py?

8-Bit Borges
  • 8,924
  • 25
  • 82
  • 157
  • 2
    this can be helpful http://stackoverflow.com/questions/4383571/importing-files-from-different-folder-in-python – Bijoy Feb 18 '17 at 04:26

1 Answers1

4

You can use the following in tags.py:

import sys
sys.path.append('../')
from search.blogs import crawler
andrew
  • 4,171
  • 2
  • 22
  • 26
  • If you use four spaces instead of backticks for code blocks, you'll get syntax highlighting. – Ben Feb 20 '17 at 02:45