[Tutor] TypeError
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Fri Feb 27 14:00:12 EST 2004
On Fri, 27 Feb 2004, Christopher Spears wrote:
> I entered the following code and got an error:
>
> >>> import UserDict
> >>> a = UserDict()
>
> 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.
Hi Chris,
Try saying:
a = UserDict.UserDict()
The reason for this is because a module like "UserDict" can hold more than
a single class.
What you may have done earlier might have been something like:
###
from UserDict import UserDict
a = UserDict()
###
where the 'from' statement allows us to pull a single thing out of a
module.
Hope this helps!
More information about the Tutor
mailing list