UnboundLocalError and new files
Since a couple of days I have a problem with my python code.
In the folder which contains my .sage files creates files with the ending .sage.py
When I do a calculation in python, subtracting one and get the following error:
UnboundLocalError: local variable '_sage_const_1' referenced before assignment
About the line the causes the error, it is simply:
print(len(Q)-1)
Where Q is a list. I run my files in a linux terminal with the command "sage filename", didn't experience this problem before.
Would be really have to work this out or even understand why this happens.
Without a (possibly minimal) (non-)working example, it is difficult to give any reasonable advice. Could you create one, as well as telling us which version of Sage you use, on which platform, and how you installed it...
In the meantime, a serious look at the "programming" chapter of the Sage tutorial could be very usefun ; look up the mentions of the preprocessor...
HTH
If you are creating "file.sage", then you should look at the autogenerated "file.sage.py" to see if there is anything suspicious about it.