Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (47.6k points)

I have two python modules:

import b 

def hello(): 

print "hello" 

print "" 

print hello() 

print b.hi()

import a 

def hi(): 

print "hi"

When I run, I get:

AttributeError: 'module' object has no attribute 'hi'

What does the error mean? How do I fix it?

1 Answer

0 votes
by (106k points)

If you really must have mutual imports in Python, the way to do it is to import them within a function:

def cause_a_to_do_something():

import a 


Browse Categories