467,858 Members | 1,693 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,858 developers. It's quick & easy.

TypeError: 'module' object is not callable

Hello everyone!
i have the following test code:
class temp:
def __init__(self):
self.hello = "hello world!"
def printworld(self):
print(self.hello)
t = temp()

and i tried to call profile('t.printworld()')

but i received the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'module' object is not callable

I'm not sure what is wrong exactly, if anyone can point me to the
right direction, it would be much appreciated!

Mar 16 '07 #1
  • viewed: 9105
Share:
3 Replies
On Mar 16, 12:42 pm, randomt...@gmail.com wrote:
Hello everyone!
i have the following test code:
class temp:
def __init__(self):
self.hello = "hello world!"
def printworld(self):
print(self.hello)
t = temp()

and i tried to call profile('t.printworld()')

but i received the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'module' object is not callable

I'm not sure what is wrong exactly, if anyone can point me to the
right direction, it would be much appreciated!


If you're using the profile module, you need to do something like

profile.run('t.printworld()')

Good luck,

Mike

Mar 16 '07 #2
Hi,

I can't find any documentation on the profile() function. But it
might take a function reference as an argument and not the string you
are feeding it. For instance:

profile(t.printworld)

Note the difference between:

t.printworld
t.printworld()

The latter executes the function and then replaces the function call
with the return value of the function.

Mar 16 '07 #3
En Fri, 16 Mar 2007 14:42:49 -0300, <ra********@gmail.comescribió:
and i tried to call profile('t.printworld()')

but i received the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'module' object is not callable
It's always better to post the *whole* code.
I assume you wrote:
import profile
profile('...')
But profile is the module name; you want to call the `run` function inside
the profile module instead:

import profile
profile.run('t.printworld()')

Look at the docs for the profile module at
http://docs.python.org/lib/lib.html or typing help(profile) at the
interpreter prompt.

--
Gabriel Genellina

Mar 17 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Atul Kshirsagar | last post: by
7 posts views Thread by ‘5ÛHH575-UAZWKVVP-7H2H48V3 | last post: by
5 posts views Thread by Randall Parker | last post: by
1 post views Thread by Gary Wessle | last post: by
10 posts views Thread by Charles Russell | last post: by
2 posts views Thread by AWasilenko | last post: by
33 posts views Thread by christophertidy | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.