Python Forum

Full Version: Unresolved reference problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In the function

def parse_message(msg_data):
    ival = 0
    fval = 0.0
    opcode = msg_data[3]
    
    if opcode == MSG_OPCODE_VALUE:
        ival = (msg_data[8] << 24) | (msg_data[7] << 16) | (msg_data[6]<< 8) | msg_data[5])
        fval = ival / 10000.0

    return fval
I get - Unresolved reference 'msg_data'. Do I miss something?

Sorry. The last bracket is excessive. It generated the error.
I get a syntax error from the extra parenthesis in
ival = (msg_data[8] << 24) | (msg_data[7] << 16) | (msg_data[6]<< 8) | msg_data[5])
If I remove that, the code appears to work fine.

I cannot find a way to make this code generate an Unresolved Reference error.