473,473 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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
3 9757
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Atul Kshirsagar | last post by:
Hello, I am using Python 2.3.2 with a C++ extention DLL in muti-threaded environment. 1. For each new thread I create a separate sub-interpreter. 2. Each thread executes multiple python...
7
by: ‘5ÛHH575-UAZWKVVP-7H2H48V3 | last post by:
(see end of message for example code) When an instance has a dynamically assigned instance method, deepcopy throws a TypeError with the message "TypeError: instancemethod expected at least 2...
5
by: Randall Parker | last post by:
Using Python 2.4.2 on Windows 2000 in SPE. Getting: TypeError: 'str' object is not callable on this line: TmpErrMsg1 = "State machine %s " (StateMachineName) In Winpdb 1.0.6 the...
1
by: Gary Wessle | last post by:
dear python users I am not sure why I am getting **************************************************************** Traceback (most recent call last): File "my.py", line 3, in ?...
10
by: Charles Russell | last post by:
Why does this work from the python prompt, but fail from a script? How does one make it work from a script? #! /usr/bin/python import glob # following line works from python prompt; why not in...
2
by: AWasilenko | last post by:
I'm trying to test a few different approaches to displaying pages via Cherrypy and I'm not having much luck. Here is my code so far: import sys, cherrypy, html class Root: @cherrypy.expose...
33
by: christophertidy | last post by:
Hi I am new to Python and have recieved this error message when trying to instantiate an object from a class from another file within the same directory and wondered what I have done wrong. I...
18
by: Charlie of Bolton | last post by:
Hi, everybody, Did work hard on this one, as I`m a newbies... I did write the entire below script... This script is suppose to ping: a primary IP (only one), (entered manually w raw-input) ...
1
by: Charles Fox | last post by:
Hi gys -- I am looking at Numpy but getting this error when I try to get array sizes. I'm using Ubuntu Edgy with standard repositories and scipy. Any ideas? Am I doing something wrong or is it...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.