Python Forum
Unresolved reference problem - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Unresolved reference problem (/thread-38477.html)



Unresolved reference problem - john7 - Oct-18-2022

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.


RE: Unresolved reference problem - deanhystad - Oct-18-2022

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.