Debugging trick

To make the debugger prompt pop up at a specific place, paste the following line in a script or module:

  import pdb; pdb.set_trace()

Log a maximum of once every second

Quick and dirty way of limiting the rate of logging:

    from datetime import datetime
    class x(object):
    def __init__(self):
        self.prevsec = None
    def dosomework(self):
        timestamp =
        if(self.prevsec is None or self.prevsec != timestamp.second):
            self.log.debug("Data is updated")
        self.prevsec = timestamp.second

Dump to hex

See here:

Identifying a variable

There are several functions you can use to learn more about a variable. The manual says:

Basically, I use type() to test simple stuff like int or str or what have you. To test the class of an object, I use isinstance(someParameter, MyWellKnownClass).

Usage should be kept limited, for good reasons, see: