python - Imported module cannot let me use the function it contains -


i'm using 2010 head first book python, chapter 2. i've created module called nester, contains function print_lol, made program should import nester, create little list, , call function print_lol contained in nester. doesn't work, tho.

import nester  cast = ["palin", "cleese", "idle", "jones", "gilliam", "and chapman."]  nester.print_lol(cast) 

this program, , output:

> traceback (most recent call last):    file "<pyshell#2>", line 1, in <module>    nester.print_lol(cast) attributeerror: module 'nester' has no attribute 'print_lol' 

what's wrong that? why happens? code in book, same path, environment paths ok. what's wrong?

here 'nester' code, , works properly.

def print_lol(the_list):  each_item in the_list:     if isinstance(each_item, list):         print_lol(each_item)         else:             print(each_item) 

also, nester it's in c:\nester. contains setup.py, nester.py, , installation folders , files: manifest, lib, dist, build.

since import nester didn't throw in error, means script can import nester. try (explicit function import)

from nester import print_lol 

if fails, make sure print_lol exist in nester, in there no spelling mistakes.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -