By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

TypeError: 'module' object is not callable

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.