UnboundLocalError in TKinter, SQLAlchemy script.

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Mar 18 18:38:36 EDT 2015


On Thu, 19 Mar 2015 06:42 am, Chris Kavanagh wrote:

> While I appreciate the help greatly I thought I had put the entire
> traceback of the error. I was posting here and on StackOverflow, and
> suppose I got confused.

We all make mistakes. I got distracted and forgot to link you to 

http://sscce.org/

("Short, Self Contained, Correct (Compilable), Example") which might have
helped you understand where I was coming from.

I understand that when you're focused on fixing this one error, its hard to
care about the big picture, but the bigger picture is that the error you
had was actually a pretty basic problem. Learning how to debug your own
code is the most important thing we can teach you, in the sense of the old
proverb about giving a person a fish versus teaching them how to fish.

What I hope you learned from my post is:

- The traceback contains valuable debugging information, particularly 
  when it shows the actual line of code that fails. If you're not 
  reading it, you should. If you're not understanding it, you should
  ask about it.

- Most bugs are localised, and if you can isolate the bug, not only 
  do you help us to help you, but you may even solve the problem 
  yourself.

- And *least important of all*, hopefully I gave you some solutions
  to your immediate problem.


> 2nd, you say you "don't want to play guessing games", yet complain about
> "300 lines of irrelevant code", lol. Which way is it? Do you want the
> code, or not? How do I know what's relevant or irrelevant when I'm clearly
> confused? On Stack, if you don't post the entire code, you are asked to do
> so. I would think it would be the same procedure here.

I'm pretty sure that on Stackoverflow they don't insist on you posting your
entire program. What if it is 100,000 lines of code split over twenty
files? I think they ask for the same as the SSCCE site above, a minimum
sample of code which they can run and see the error themselves.

Have you got a solution to your immediate problem now, or are you still
looking for help?




-- 
Steven




More information about the Python-list mailing list