oTree Forum >

Referencing a constant in function defined in group gives this error: UnboundLocalError: local variable 'C' referenced before assignment

#1 by noob_forever

I have defined a function at the group level for use on a waiting page. In this function, I try to use a constant. 

Suppose the constant is defined as MY_CONSTANT=some value 

When I try to use group.some_var = something*C.MY_CONSTANT I get the error message "UnboundLocalError: local variable 'C' referenced before assignment". 

What is really confusing me is that I reference MY_CONSTANT in exactly the same way in a different group-level function called on a previous waiting page. 

Any idea what might be going on?

#2 by Chris_oTree

Is your constants class called “C” or “Constants”? C is the newer format.

Or can you attach the file in question.

Write a reply

Set forum username