[Tutor] TypeError

hcohen2 hcohen2 at comcast.net
Fri Feb 27 13:00:05 EST 2004


Christopher Spears wrote:

>I entered the following code and got an error:
>
>  
>
>>>>import UserDict
>>>>a = UserDict()
>>>>        
>>>>
You are using a function or class in UserDict without identifying the 
owning module.
a = UserDict.UserDict() #assuming the latter is a defined 
method/function it should now work.

However had you

from UserDict import UserDict

it should then work.  Besides not being the preferred import syntax, if 
later you wanted another function/class from this module it would be 
unknown.

>Traceback (most recent call last):
>  File "<pyshell#3>", line 1, in -toplevel-
>    a = UserDict()
>TypeError: 'module' object is not callable
>
>What does this mean?  I am trying to use the UserDict
>class, which is is located in the UserDict module. 
>When I normally assign a class to a variable, the
>above syntax works.  This is especially frustrating to
>me because I know I was able to do this yesterday.
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>  
>





More information about the Tutor mailing list