help with NameError

Shadri Shah shadri_shah at hotmail.com
Tue May 27 11:05:16 EDT 2003


Hello,

I request help in understanding why I'm getting NameError here in the code below:

import re

def t(s):
    k = []
    
    def g(j):
        global k
        k.append(j.group(0))
        return 'p'
    
    re.sub('f',g,s)
    
    print k

if __name__ == "__main__":
    t('abc f xyz f')



Thanks in advance,
Shadri




More information about the Python-list mailing list