UnboundLocalError and new files

asked 2022-03-06 16:15:12 +0200

schwabis gravatar image

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.

edit retag flag offensive close merge delete

Comments

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

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-03-06 17:54:11 +0200 )edit

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.

John Palmieri gravatar imageJohn Palmieri ( 2022-03-06 18:36:16 +0200 )edit