Erik Max Francis wrote:
[EMAIL PROTECTED] wrote:

UnboundLocalError: local variable 't2' referenced before assignment

...

t2=""

def Proc(text): # "text" is some random text or use OrigText
    ...

The fix is to declare t2 global at the top of Proc:

    def Proc(text):
        global t2
        ...

But please don't. The global declaration is a wart of Python, and in most cases, your code will be much cleaner if you avoid it. Certainly in this case, making t2 a local of the function is much more sensible. If you stick with your current implementation (which I advise against), you should write it something like:


def proc(text):
    t2 = ""
    ...
    # your Proc code here
    ...
    return t2

Steve
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to