[Tutor] str object is not callable

2012-07-10 Thread Chris Hare
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

Re: [Tutor] str object is not callable

2012-07-10 Thread Devin Jeanpierre
On Tue, Jul 10, 2012 at 10:56 AM, Chris Hare ch...@labr.net wrote: 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

Re: [Tutor] str object is not callable

2012-07-10 Thread Dave Angel
On 07/10/2012 10:56 AM, Chris Hare wrote: 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)) You just

Re: [Tutor] str object is not callable

2012-07-10 Thread Prasad, Ramit
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

Re: [Tutor] str object is not callable

2012-07-10 Thread Brian van den Broek
On 10 Jul 2012 11:31, Chris Hare ch...@labr.net wrote: This piece of code works: Big-Mac:Classes chare$ more tmp.py import re snip return not bool(search(string)) snip However, when I use the EXACT same code in the context of the larger code, I get the error return not

Re: [Tutor] str object is not callable

2012-07-10 Thread Steven D'Aprano
Chris Hare wrote: def special_match(string, search=re.compile(r'[^a-zA-Z0-9\.\ \-\#\$\*\@\!\%\^\]').search): #string = string.rstrip() return not bool(search(string)) The call to bool is redundant. Get rid of it. The not operator will automatically convert its argument into a

Re: [Tutor] str object is not callable

2012-07-10 Thread Chris Hare
Okay - I am officially embarrassed. As you might now, I am splitting this 10,000 line file apart, and that is posing certain challenges which I am fixing, and cleaning up stuff that was broken and visible only when doing this split. This is one of them. What I failed to remember -- and

Re: [Tutor] str object is not callable

2012-07-10 Thread Steven D'Aprano
Chris Hare wrote: Okay - I am officially embarrassed. [...] Meh, don't beat yourself up too badly. We've all been where you are now. Sometimes I look back at my early Python code... I tell you, that's always a good antidote for a big head. -- Steven

Re: [Tutor] str object is not callable

2012-07-10 Thread Wayne Werner
On Wed, 11 Jul 2012, Steven D'Aprano wrote: Chris Hare wrote: Okay - I am officially embarrassed. [...] Meh, don't beat yourself up too badly. We've all been where you are now. Sometimes I look back at my early Python code... I tell you, that's always a good antidote for a big head. I