Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-19 Thread Terry Reedy
On 3/19/2015 4:23 AM, Chris Kavanagh wrote: On Wednesday, March 18, 2015 at 5:37:53 PM UTC-4, Terry Reedy wrote: You comment out apparently irrelevant lines and see if you still have the same problem, and if you do, delete. Repeat until you have a Minimal Complete Verifiable Example. Thank

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-19 Thread Chris Kavanagh
On Wednesday, March 18, 2015 at 5:37:53 PM UTC-4, Terry Reedy wrote: > On 3/18/2015 3:42 PM, Chris Kavanagh wrote: > > > 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 kno

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-19 Thread Chris Kavanagh
On Wednesday, March 18, 2015 at 5:50:49 PM UTC-4, Mark Lawrence wrote: > On 18/03/2015 19:42, Chris Kavanagh wrote: > > > > 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

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-19 Thread Chris Kavanagh
On Wednesday, March 18, 2015 at 6:38:48 PM UTC-4, Steven D'Aprano wrote: > 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 confuse

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Steven D'Aprano
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

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Mark Lawrence
On 18/03/2015 19:42, Chris Kavanagh wrote: 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'

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Terry Reedy
On 3/18/2015 3:42 PM, Chris Kavanagh wrote: 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? You comment out appare

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Chris Kavanagh
On Wednesday, March 18, 2015 at 8:02:14 AM UTC-4, Steven D'Aprano wrote: > On Wed, 18 Mar 2015 01:41 pm, Chris Kavanagh wrote: > > > I have a simple script that takes user input (for an Employee) such as > > name, age, etc then puts in an sqlite3 database. The script worked fine > > until I realiz

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Steven D'Aprano
On Wed, 18 Mar 2015 01:41 pm, Chris Kavanagh wrote: > I have a simple script that takes user input (for an Employee) such as > name, age, etc then puts in an sqlite3 database. The script worked fine > until I realized one problem. The age input field is defined in SQLAlchemy > as an Integer, so if

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread ckava3
On Wednesday, March 18, 2015 at 12:00:54 AM UTC-4, MRAB wrote: > On 2015-03-18 02:41, Chris Kavanagh wrote: > > I have a simple script that takes user input (for an Employee) such as > > name, age, etc then puts in an sqlite3 database. The script worked fine > > until I realized one problem. The ag

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-17 Thread MRAB
On 2015-03-18 02:41, Chris Kavanagh wrote: I have a simple script that takes user input (for an Employee) such as name, age, etc then puts in an sqlite3 database. The script worked fine until I realized one problem. The age input field is defined in SQLAlchemy as an Integer, so if a user inputs a

Re: UnboundLocalError: local variable referenced before assignment

2010-06-08 Thread danieldelay
Le 08/06/2010 10:03, ch1zra a écrit : import os, time, re, pyodbc, Image, sys from datetime import datetime, date, time from reportlab.lib.pagesizes import A4 from reportlab.lib.units import cm from reportlab.pdfgen import canvas from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttf

Re: UnboundLocalError: local variable referenced before assignment

2010-06-08 Thread Bruno Desthuilliers
ch1zra a écrit : On Jun 8, 10:59 am, Bryan wrote: Python doesn't have one global namespace. Each module (file) has its own namespace, which is a Python dict, and 'global' means defined in the containing module's dict. Put the import: from reportlab.pdfgen import canvas in the mkTable.py fil

Re: UnboundLocalError: local variable referenced before assignment

2010-06-08 Thread Bryan
Peter Otten wrote: > Chris Rebert wrote: [...] > > The only global variable defined in mkTable.py is the "mkTable" > > function (partly since you don't import anything). So the reference to > > the global variable "canvas" on the right-hand side of this expression > > is completely undefined, resul

Re: UnboundLocalError: local variable referenced before assignment

2010-06-08 Thread Peter Otten
Chris Rebert wrote: > On Tue, Jun 8, 2010 at 2:00 AM, ch1zra wrote: >> On Jun 8, 10:29 am, Richard Thomas wrote: >>> On Jun 8, 9:03 am, ch1zra wrote: >>> > I have following code : >>> >>> > import os, time, re, pyodbc, Image, sys >>> > from datetime import datetime, date, time >>> > from report

Re: UnboundLocalError: local variable referenced before assignment

2010-06-08 Thread ch1zra
On Jun 8, 10:59 am, Bryan wrote: > ch1zra wrote: > > I have following code : > > > import os, time, re, pyodbc, Image, sys > > from datetime import datetime, date, time > > from reportlab.lib.pagesizes import A4 > > from reportlab.lib.units import cm > > from reportlab.pdfgen import canvas > > fro

Re: UnboundLocalError: local variable referenced before assignment

2010-06-08 Thread Chris Rebert
On Tue, Jun 8, 2010 at 2:00 AM, ch1zra wrote: > On Jun 8, 10:29 am, Richard Thomas wrote: >> On Jun 8, 9:03 am, ch1zra wrote: >> > I have following code : >> >> > import os, time, re, pyodbc, Image, sys >> > from datetime import datetime, date, time >> > from reportlab.lib.pagesizes import A4 >>

Re: UnboundLocalError: local variable referenced before assignment

2010-06-08 Thread ch1zra
On Jun 8, 10:29 am, Richard Thomas wrote: > On Jun 8, 9:03 am, ch1zra wrote: > > > > > > > I have following code : > > > import os, time, re, pyodbc, Image, sys > > from datetime import datetime, date, time > > from reportlab.lib.pagesizes import A4 > > from reportlab.lib.units import cm > > from

Re: UnboundLocalError: local variable referenced before assignment

2010-06-08 Thread Bryan
ch1zra wrote: > I have following code : > > import os, time, re, pyodbc, Image, sys > from datetime import datetime, date, time > from reportlab.lib.pagesizes import A4 > from reportlab.lib.units import cm > from reportlab.pdfgen import canvas > from reportlab.pdfbase import pdfmetrics > from repor

Re: UnboundLocalError: local variable referenced before assignment

2010-06-08 Thread Richard Thomas
On Jun 8, 9:03 am, ch1zra wrote: > I have following code : > > import os, time, re, pyodbc, Image, sys > from datetime import datetime, date, time > from reportlab.lib.pagesizes import A4 > from reportlab.lib.units import cm > from reportlab.pdfgen import canvas > from reportlab.pdfbase import pdf

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Dave Angel
Gabriel Rossetti wrote: Dave Angel wrote: Gabriel Rossetti wrote: Hello everyone, I get this error on python 2.6.1 on mac os x 10.6 : UnboundLocalError: local variable '_[1]' referenced before assignment here's the code that raises this: params = [ self.__formatData(paramProcFunc, query, p

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Terry Reedy
Gabriel Rossetti wrote: Gabriel Rossetti wrote: I get this error on python 2.6.1 on mac os x 10.6 : UnboundLocalError: local variable '_[1]' referenced before assignment here's the code that raises this: params = [ self.__formatData(paramProcFunc, query, p) for p in params ] what I don't g

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Hrvoje Niksic
Richard Thomas writes: > That isn't an error that should occur, not least because _[1] isn't a > valid name. Can you post a full traceback? The name _[n] is used internally when compiling list comprehensions. The name is chosen precisely because it is not an (otherwise) valid identifier. For ex

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Gabriel Rossetti
Dave Angel wrote: Gabriel Rossetti wrote: Hello everyone, I get this error on python 2.6.1 on mac os x 10.6 : UnboundLocalError: local variable '_[1]' referenced before assignment here's the code that raises this: params = [ self.__formatData(paramProcFunc, query, p) for p in params ] what

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Bruno Desthuilliers
Richard Thomas a écrit : On Dec 9, 10:17 am, Gabriel Rossetti wrote: UnboundLocalError: local variable '_[1]' referenced before assignment That isn't an error that should occur, not least because _[1] isn't a valid name It's an internal identifier used in list comps. Implementation detail

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Dave Angel
Gabriel Rossetti wrote: Hello everyone, I get this error on python 2.6.1 on mac os x 10.6 : UnboundLocalError: local variable '_[1]' referenced before assignment here's the code that raises this: params = [ self.__formatData(paramProcFunc, query, p) for p in params ] what I don't get is tha

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Richard Thomas
On Dec 9, 10:17 am, Gabriel Rossetti wrote: > Hello everyone, > > I get this error on python 2.6.1 on mac os x 10.6 : > > UnboundLocalError: local variable '_[1]' referenced before assignment > > here's the code that raises this: > > params = [ self.__formatData(paramProcFunc, query, p) for p in p

Re: UnboundLocalError with extra code after return

2009-09-30 Thread John Posner
Duncan Booth wrote: / class CallableOnlyOnce(object): /def __init__(self, func): self.func = func def __call__(self): f = self.func if f: self.func = None return f() / def callonce(func): / return CallableOnlyOnce(func) / @callonce /

Re: UnboundLocalError with extra code after return

2009-09-30 Thread Duncan Booth
Rich Healey wrote: > It seems that my problem was that I can't assign a new function to the > name func within the callonce() function. I can however interact with > the func object (in this case storing information about whether or not > I'd called it in it's __RECALL item. > > Is there a clean

Re: UnboundLocalError with extra code after return

2009-09-29 Thread Albert Hopkins
On Tue, 2009-09-29 at 21:15 -0700, Rich Healey wrote: > However: > > def callonce(func): > def nullmethod(): pass > def __(): > return func() > func = nullmethod > return ret > return __ > > @callonce > def t2(): > print "T2 called" > t2() > > Gives me: >

Re: UnboundLocalError with extra code after return

2009-09-29 Thread Chris Rebert
On Tue, Sep 29, 2009 at 9:41 PM, Chris Rebert wrote: > On Tue, Sep 29, 2009 at 9:15 PM, Rich Healey wrote: >> However: >> >> def callonce(func): >>    def nullmethod(): pass >>    def __(): >>        return func() >>        func = nullmethod Additionally, to rebind a variable in an outer nested

Re: UnboundLocalError with extra code after return

2009-09-29 Thread Chris Rebert
On Tue, Sep 29, 2009 at 9:15 PM, Rich Healey wrote: > However: > > def callonce(func): >    def nullmethod(): pass >    def __(): >        return func() >        func = nullmethod When Python sees this assignment to func as it compiles the __() method, it marks func as a local variable and will n

Re: UnboundLocalError with extra code after return

2009-09-29 Thread Rich Healey
On Sep 30, 2:15 pm, Rich Healey wrote: > I'm trying to write a decorator that causes a function to do nothing > if called more than once- the reason for this is trivial and to see if > I can (Read- I'm enjoying the challenge, please don't ruin it for me > =] ) > > However I'm getting strange resul

Re: UnboundLocalError - (code is short & simple)

2009-09-28 Thread New User
illiers wrote: From: Bruno Desthuilliers Subject: Re: UnboundLocalError - (code is short & simple) To: python-list@python.org Date: Monday, September 28, 2009, 8:24 AM Chris Rebert a écrit : > On Sun, Sep 27, 2009 at 8:5

Re: UnboundLocalError - (code is short & simple)

2009-09-28 Thread New User
rtin --- On Mon, 9/28/09, Chris Kaynor wrote: From: Chris Kaynor Subject: Re: UnboundLocalError - (code is short & simple) To: python-list@python.org Date: Monday, September 28, 2009, 4:00 PM On Sun, Sep 27, 2009 at 10:39 PM, New User wrote: Hi Chris, Thank you for the reply and info!

Re: UnboundLocalError - (code is short & simple)

2009-09-28 Thread Chris Kaynor
on the python list - I just forgot to remove you from it (I used G-Mail's reply all). In general, unless the reply is off-topic or personal, it should be replied to on-list. This allows more people to both see the answer and to help further explain the answer. > > --- On *Mon, 9/28/09, Chris Ka

Re: UnboundLocalError - code is short & simple

2009-09-28 Thread Francesco Bochicchio
On Sep 28, 6:07 am, pylearner wrote: > System Specs: > > Python version = 2.6.1 > IDLE > Computer = Win-XP, SP2 (current with all windows updates) > > ---­- > > Greetings: > > I have written code for two things:  1

Re: UnboundLocalError - (code is short & simple)

2009-09-28 Thread Bruno Desthuilliers
Chris Rebert a écrit : On Sun, Sep 27, 2009 at 8:53 PM, pylearner wrote: --- Traceback (most recent call last): File "", line 1, in toss_winner() File "C:/Python26/toss_winner.py", line 7, in toss_winner coin_toss = coin

Re: UnboundLocalError - (code is short & simple)

2009-09-27 Thread Chris Rebert
On Sun, Sep 27, 2009 at 8:53 PM, pylearner wrote: > --- > > Traceback (most recent call last): >  File "", line 1, in >    toss_winner() >  File "C:/Python26/toss_winner.py", line 7, in toss_winner >    coin_toss = coin_toss() > Unb

Re: UnboundLocalError - (code is short & simple)

2009-09-27 Thread Chris Kaynor
Lets look at what is happening on a few of the lines here: First: from coin_toss import coin_toss imports the module coin_toss and sets the local variable coin_toss to the value of coin_toss in the module coin_toss. Second: coin_toss = coin_toss() calls the function bound to the name coin_toss

Re: UnboundLocalError problems

2008-06-29 Thread Terry Reedy
Mr SZ wrote: Hi, I am writing a small script that changes my pidgin status to away when I lock my screen.I'm using the DBUS API for pidgin and gnome-screensaver.Here's the code: #!/usr/bin/env python import dbus, gobject from dbus.mainloop.glib import DBusGMainLoop dbus.mainloop.glib.DBu

Re: UnboundLocalError on global variable

2007-09-09 Thread GuillaumeC
> def processLogEntry(entry): # ADD THIS TO YOUR CODE global cmterID_ > >revision = int(entry.getRevision()) >commiter = str(entry.getAuthor()) >datetime = getTimeStamp(entry.getDate()) >message = str(entry.getMessage()) > >Commiter_[0] = cmterID_ //HERE's THE PROBLEM The r

Re: UnboundLocalError on global variable

2007-09-09 Thread GuillaumeC
> def processLogEntry(entry): # ADD THIS TO YOUR CODE global cmterID_ > >revision = int(entry.getRevision()) >commiter = str(entry.getAuthor()) >datetime = getTimeStamp(entry.getDate()) >message = str(entry.getMessage()) > >Commiter_[0] = cmterID_ //HERE's THE PROBLEM The r

Re: UnboundLocalError

2006-11-11 Thread Camellia
Oh thank you for pointing that out Fredrik, you made the case more clear:) On Nov 11, 7:19 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Camellia wrote: > > Oh how can I thank you enough, you make my day:) > > According to what you said I finally figure it out, it is the same as: > > > > > b = 1

Re: UnboundLocalError

2006-11-11 Thread Fredrik Lundh
Camellia wrote: > Oh how can I thank you enough, you make my day:) > According to what you said I finally figure it out, it is the same as: > > > b = 1 > def a(): > b = b #no good:) > if you really want to modify a variable that lives outside the function, you can use the "global" directi

Re: UnboundLocalError

2006-11-11 Thread Camellia
Oh how can I thank you enough, you make my day:) According to what you said I finally figure it out, it is the same as: b = 1 def a(): b = b #no good:) So in every day programming I should avoid using the same name for different types of objects because they will step on each other, right?

Re: UnboundLocalError

2006-11-11 Thread Camellia
Oh how can I thank you enough, you make my day:) According to what you said I finally figure it out, it is the same as: b = 1 def a(): b = b #no good:) So in every day programming I should avoid using the same name for different objects because they will step on each other, right? On Nov 1

Re: UnboundLocalError

2006-11-10 Thread Gabriel Genellina
At Saturday 11/11/2006 02:35, Camellia wrote: But sorry I'm so dumb I can't say I really understand, what do I actually do when I define a function with its name "number"? Don't apologize, Python is a lot more dumb than you. It obeys very simple rules (a good thing, so we can clearly understa

Re: UnboundLocalError

2006-11-10 Thread Camellia
Thank you all so much for all the replies:) But sorry I'm so dumb I can't say I really understand, what do I actually do when I define a function with its name "number"? why does a name of a function has something to do with a variable? Oh wait can I do this in Python?: def a(): def b() so

Re: UnboundLocalError

2006-11-09 Thread Rob Williscroft
Terry Reedy wrote in news:[EMAIL PROTECTED] in comp.lang.python: >> def main(): >>number = number() > > Within a function, a given name can be either global or local, but not > both. > Here you are expecting the compiler to interpret the first occurance > of 'number' as local and the second

Re: UnboundLocalError

2006-11-09 Thread Terry Reedy
"Camellia" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi all > > why it generates an "UnboundLocalError" when I do the following: > > > ... Presumably, the elided code includes a 'def number():' statement > def main(): >number = number() Within a function, a given name

Re: UnboundLocalError

2006-11-09 Thread Benjamin Niemann
Hello, Camellia wrote: > why it generates an "UnboundLocalError" when I do the following: > > > ... > def main(): > number = number() > number_user = user_guess() > while number_user != number: > check_number(number = number, number_user = number_user) > number_user

Re: unboundlocalerror with cgi module

2006-04-11 Thread bruno at modulix
David Bear wrote: > I'm attempting to use the cgi module with code like this: > > import cgi > fo = cgi.FieldStorage() > # form field names are in the form if 'name:part' > keys = fo.keys() > for i in keys: > try: > item,value=i.split(':') > except NameError, Unboun

Re: unboundlocalerror with cgi module

2006-04-10 Thread Tim Hochberg
Kent Johnson wrote: > Tim Hochberg wrote: > >>Kent Johnson wrote: >> >>>David Bear wrote: >>> >>> I'm attempting to use the cgi module with code like this: import cgi fo = cgi.FieldStorage() # form field names are in the form if 'name:part' keys = fo.keys() for i in ke

Re: unboundlocalerror with cgi module

2006-04-10 Thread Fredrik Lundh
"David Bear" wrote: > I'm attempting to use the cgi module with code like this: > > import cgi > fo = cgi.FieldStorage() > # form field names are in the form if 'name:part' > keys = fo.keys() > for i in keys: > try: > item,value=i.split(':') > except NameError, Unbo

Re: unboundlocalerror with cgi module

2006-04-10 Thread Tim Hochberg
Tim Hochberg wrote: > Kent Johnson wrote: > >>David Bear wrote: >> >> >>>I'm attempting to use the cgi module with code like this: >>> >>>import cgi >>>fo = cgi.FieldStorage() >>># form field names are in the form if 'name:part' >>>keys = fo.keys() >>>for i in keys: >>> try: >>>

Re: unboundlocalerror with cgi module

2006-04-10 Thread Kent Johnson
Tim Hochberg wrote: > Kent Johnson wrote: >> David Bear wrote: >> >>> I'm attempting to use the cgi module with code like this: >>> >>> import cgi >>> fo = cgi.FieldStorage() >>> # form field names are in the form if 'name:part' >>> keys = fo.keys() >>> for i in keys: >>>try: >>>

Re: unboundlocalerror with cgi module

2006-04-10 Thread Tim Hochberg
Kent Johnson wrote: > David Bear wrote: > >>I'm attempting to use the cgi module with code like this: >> >>import cgi >>fo = cgi.FieldStorage() >># form field names are in the form if 'name:part' >>keys = fo.keys() >>for i in keys: >>try: >>item,value=i.split(':') >>

Re: unboundlocalerror with cgi module

2006-04-10 Thread Kent Johnson
David Bear wrote: > I'm attempting to use the cgi module with code like this: > > import cgi > fo = cgi.FieldStorage() > # form field names are in the form if 'name:part' > keys = fo.keys() > for i in keys: > try: > item,value=i.split(':') > except NameError, Unboun

Re: unboundlocalerror with cgi module

2006-04-10 Thread Felipe Almeida Lessa
Em Seg, 2006-04-10 às 11:29 -0700, David Bear escreveu: > However, the except block does not seem to catch the exception and an > unboundlocalerror is thrown anyway. What am I missing? See http://docs.python.org/tut/node10.html : """ A try statement may have more than one except clause, to specif

Re: UnboundLocalError: local variable 'colorIndex' referenced

2006-02-26 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: > Can you please tell me what is the meaning this error in general? > > UnboundLocalError: local variable 'colorIndex' referenced before > assignment > > In my python script, > I have a variable define and init to 0, like this > colorIndex = 0 > > and in one of my fu

Re: UnboundLocalError: local variable 'colorIndex' referenced

2006-02-26 Thread Rick Zantow
[EMAIL PROTECTED] wrote in news:1140987642.195734.187540 @t39g2000cwt.googlegroups.com: > Can you please tell me what is the meaning this error in general? > > UnboundLocalError: local variable 'colorIndex' referenced before > assignment > > In my python script, > I have a variable define and i