This piece of code works:
Big-Mac:Classes chare$ more tmp.py
import re
def special_match(string, search=re.compile(r'[^a-zA-Z0-9\.\
\-\#\$\*\@\!\%\^\&]').search):
#string = string.rstrip()
return not bool(search(string))
print special_match("admin")
print special_match("&!*")
print special_match("=")
Big-Mac:Classes chare$ python tmp.py
True
True
False
Big-Mac:Classes chare$
However, when I use the EXACT same code in the context of the larger code, I
get the error
return not bool(search(strg))
TypeError: 'str' object is not callable
The input to the function in the larger program is the same as the first test
in the small script that works -- "admin".
As a side note -- the rstrip call is also broken, although the string module is
imported. I just can't figure out why this code works in one context and not
in another.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor