Importing is partially working...

Dwight GoldWinde Dwight at
Sun Aug 9 07:45:04 CEST 2015

I am trying to import and function.
The function (humprint) is defined in a .py module inside the same folder as
the executing code.
I am put traces in the module to show that it works okay there
(Python 3.4).

Here is the code of the module:

print (callable(humprint))
except NameError:
print ('humprint not defined')
def humprint (sentence):
import random
import time
import sys
for char in sentence:
sys.stdout.write (char)
sys.stdout.flush ()
part_second = random.randint(1, 100) / 400
time.sleep(part_second) # delays for x seconds
print (callable(humprint))
sentence = 'Testing humprint inside of the same module'
humprint (sentence)

And here is the code for the calling module:

name = 'Jim'
coach = 'Dwight'
import importlib
sentence = 'Hi, there, ' + name + '. My name is ' + coach + '. I will be
your coach today.'
from import humprint
humprint (sentence)

And here are the results of running the calling module:

humprint not defined
Testing humprint inside of the same moduleTraceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2218, in
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "", line 5, in <module>
    from import humprint

ImportError: No module named ''; 'Functions' is not a package

So, it seems like it is accessing the module, but not the function?

Please advise!

With appreciationŠ.


Always, Dwight (video playlist on YouTube) (all my books on Amazon)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list