TypeError: 'module' object is not callable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • randomtalk@gmail.com

    #1

    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.hell o)
    t = temp()

    and i tried to call profile('t.prin tworld()')

    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!

  • kyosohma@gmail.com

    #2
    Re: TypeError: 'module' object is not callable

    On Mar 16, 12:42 pm, randomt...@gmai l.com wrote:
    Hello everyone!
    i have the following test code:
    class temp:
    def __init__(self):
    self.hello = "hello world!"
    def printworld(self ):
    print(self.hell o)
    t = temp()
    >
    and i tried to call profile('t.prin tworld()')
    >
    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

    Comment

    • 7stud

      #3
      Re: TypeError: 'module' object is not callable

      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.print world)

      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.

      Comment

      • Gabriel Genellina

        #4
        Re: TypeError: 'module' object is not callable

        En Fri, 16 Mar 2007 14:42:49 -0300, <randomtalk@gma il.comescribió:
        and i tried to call profile('t.prin tworld()')
        >
        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

        Comment

        Working...