HELP:UnboundLocalError: local variable '_nntp' referenced before assignment

Peter Moscatt pgmoscatt at optushome.com.au
Fri Mar 18 06:07:39 EST 2005


Hi all,

I am in the process of writing an app that will handle news feeds and
therefore using the 'nntplib'

When I issue the connect command all goes will but when I issue the 'quit()'
command I get the following error message:


Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
    return self.func(*args)
  File "./pnews.py", line 26, in callconnect
    _nntp.quit()
UnboundLocalError: local variable '_nntp' referenced before assignment


The code below illustrates how I'm using the code.  Can anyone help me out
in getting this right.

Pete


def callconnect():
        if b["text"]=="Connect":
                _nntp =
nntplib.NNTP(_global.servername,int(_global.portnumber),_global.userid,_global.userpassword)
                if(_nntp):
                        b["text"]="Disconnect"
                        
        elif b["text"]=="Disconnect":
                _nntp.quit()
                





More information about the Python-list mailing list