Callback not called if it is a class method
<p>Python newbie question: the callback method <code>handlePackets</code> never gets called if it is a class method. If it is not in a class it works fine. What can I do?</p>

<pre><code>class Receiver:

    def __enter__(self):
        self.serial_port = serial.Serial('/dev/ttyUSB0', 115200)
        self.xbee = ZigBee(self.serial_port, escaped=True,    callback=self.handlePackets)
        Logger.info('Receiver: enter')
        return self

    def __exit__(self ,type, value, traceback):
        Logger.info('Receiver: exit')
        self.serial_port.close()

    def handlePackets(data):
        Logger.info('Receiver: packet incoming')
</code></pre>

<p>I can bet it is because, whatever is calling your callback from within <code>ZigBee</code> is failing silently. The interpreter calls your function with 2 parameters, but as you have defined it -- it takes only one.</p>

<pre><code>def handlePackets(self, data):
                 #^^^^
</code></pre>

python python-2.7