0

Say, I have three files __init__.py, time.py and readers.py in a directory analogpy.

time.py has a class and readers.py has function read_file()

__init__.py has following

from analogpy import time
from analogpy import readers

when I import readers from analogpy and call the function read_file(), it shows the following error

from analogpy import readers
ImportError: cannot import name 'read_file' from 'analogpy' (analogpy/__init__.py)

Functions are clearly defined because I see they work fine when compiling individual files. What am I not understanding here?

1 Answer 1

2
  1. you can update your __init__.py like this:
from .readers import read_file

then you can from analogpy import readfile in other file and call the function

  1. or you can use
from analogpy import readers

readers.read_file()

to call the function

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.