[Tutor] str object is not callable

Chris Hare chare at labr.net
Tue Jul 10 19:35:18 CEST 2012


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 you guys are free to bash me for this  -- was so simple once I put a print in to see what the value was of the string entering the function.

I had (after modifications suggested):

def special_match(s, hunt=SPECIAL_CHARS.search):

BUT

This is defined in a Class - and I missed it.  Should have been

def special_match(self,s, hunt=SPECIAL_CHARS.search):

Sorry guys - but thanks for the excellent suggestions/advice.  I am sure not a python guru, python is my entry into OOP.  So, rest assured I come to the list after trying to figure it out, but lesson learned.  That is why it worked in one piece of code - it was standalone, and didn't work in the class where it has been moved to.  No excuse, but there it is nonetheless.

<sheepishly>
Chris



On Jul 10, 2012, at 10:33 AM, Devin Jeanpierre wrote:

> On Tue, Jul 10, 2012 at 10:56 AM, Chris Hare <chare at 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 figure out why this code works in one context and not in another.
> 
> I suspect you defined "bool" somewhere to be a string. That, or else
> you passed in a string as the search argument. Unfortunately Python
> doesn't tell you which expression raised the exception, but certainly
> it's one of those two.
> 
> -- Devin



More information about the Tutor mailing list