[Tutor] calling a module fails

richard kappler richkappler at gmail.com
Tue Oct 30 02:00:47 CET 2012


Methinks I'm missing something obvious, but can't quite put my finger on
it. If, in the interpreter, I enter the following code:

def hungry(batVolt):
     if batVolt >94:
         return ("I am not hungry at the moment")
     elif 64 < batVolt < 95:
         return ("I'm starting to get hungry")
     else:
         return ("I'm hungry!")

and then run

hungry(98)

with 98 just being an example of the many numbers I tried when testing
this, I get the return I expected and all is well.

If, however, I save the above in a file named hungry.py, then import
hungry, I get an error, as follows:

import hungry
hungry(96)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callable

So what am I missing? Someone do please point out the obvious. ;-)

regards, Richard

-- 

sic gorgiamus allos subjectatos nunc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121029/1d8d7600/attachment.html>


More information about the Tutor mailing list