def METHOD_NAME(self, code, gdbvar=None):
    if gdbvar is not None:
        d = {'varname':gdbvar, 'code':code}
        gdb.execute('set $%(varname)s = %(code)s' % d)
        code = '$' + gdbvar
    return libpython.PyObjectPtr.from_pyobject_ptr(self.get_pyobject(code))