TypeError: unbound method must be called with class instance 1st argument

Discussion in 'Python' started by Guest, Dec 21, 2006.

  1. Guest

    Guest Guest

    I'm a novice at Python, and found some code samples on how to use
    threads. My script is being run by a product that contains a Jython
    interpreter. Can someone please explain why I get the following error:

    Traceback (innermost last):
    File "/full/path/to/file/GenerateData.py", line 104, in ?
    File "/full/path/to/file/GenerateData.py", line 34, in __init__
    TypeError: unbound method must be called with class instance 1st

    Here are the important pieces of my GenerateData.py script. Note that
    "scriptinterface" is something provided by the product to allow my
    script to interface with it. Line 104 is the last line -- the one that
    creates a GenThread and calls start() on it.

    import sys

    # need this section otherwise the import random won't work
    if sys.path.count('/usr/local/lib/python2.2/') == 0:

    import random
    import time
    import threading

    from java.lang import String
    from jarray import array

    class GenThread(threading.Thread):
    def __init__(self, ipAddress, port):
    self.ipAddress = ipAddress
    self.port = str(port)

    def run(self):
    # code

    Guest, Dec 21, 2006
    1. Advertisements

  2. Guest

    Matimus Guest

    The following line:
    Should be written as:
    Matimus, Dec 21, 2006
    1. Advertisements

  3. Guest

    Guest Guest

    Thank you!
    Guest, Dec 21, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.