Diez B. Roggisch wrote:
Hari Sekhon wrote:

  
import re
re_regexname = re.compile('abc')

.....
..... various function defs
.....

def func1():
...
func2()
...

def func2():
if re_regexname.match('abc'):
<do something>

if __name__ == '__main__':
func1()
    


The above clearly is not what you have. See the attached version of the
above that works. So - go check for a typo or something like that.

Diez

import re re_regexname = re.compile('abc') def func1(): func2() def func2(): if re_regexname.match('abc'): print " whohoo!" if __name__ == '__main__': func1()
you're right, it wasn't that, I was trying to locally override a regex object as follows:

re_somepattern = re.compile('abc')
re_someotherpattern = re.compile('def')

def func():
    if somecondition:
        re_somepattern = re_someotherpattern

    <code block>
        re_somepattern.match('something')
    </code.block>

not sure how to override this the way I want, it'd be quite messy if I had to do huge if blocks to handle this inside the other code blocks that use this re_somepattern.match()

or perhaps I'm going about this all wrong....

-h

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

Reply via email to