<br>Oh, gee. Do I feel sheepish. I knew I had been staring at the error all along, but yet couldn't see it.<br><br><br>Thanks!!<br><br><div><span class="gmail_quote">On 2/17/06, <b class="gmail_sendername">Kent Johnson</b>
<<a href="mailto:kent37@tds.net">kent37@tds.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Chris Hallman wrote:
<br>><br>> Here is my script:<br>> input = file(rpath, "r")<br>> for line in file(rpath):<br><snip><br>> for file in dirList:<br>> filename = file.lower()<br><br>You use the name 'file' for a global variable. This hides the builtin
<br>function 'file'. This is a bit of a gotcha for newbies - the names of<br>builtins are not reserverd words, so they can be reasigned to your own<br>variables. Some of the names that are commonly (mis)used this way are<br>
file, list and dict. You just have to learn not to do this.<br><br>When you try<br> input = file(rpath, "r")<br>file contains a string value, which is not callable the way a function<br>is. Hence the error.<br>
<br>The fix is to use a different name for your variable, e.g. 'f'.<br><br>Also you are opening the file twice, you don't need the very first line<br>above. And 'input' is also the name of a builtin ;)<br><br>For reference, here is a list of the built-in functions:
<br><a href="http://docs.python.org/lib/built-in-funcs.html">http://docs.python.org/lib/built-in-funcs.html</a><br><br>> Here is the error:<br>><br>> >pythonw -u "send_file.py"<br>> c:\temp\config\rtr0544.txt
<br>> Exception in thread Thread-1:<br>> Traceback (most recent call last):<br>> File "c:\python24\lib\threading.py", line 442, in __bootstrap<br>> self.run()<br>> File "send_file.py", line 45, in run
<br>> input = file(rpath, "r")<br>> TypeError: 'str' object is not callable<br><br>OK, this is saying that you are trying to call a string object, and<br>strings can't be called. You call something with the () syntax. So the
<br>thing you are trying to call is the value of the symbol 'file'.<br>Evidently that is a string rather than the built-in file function.<br><br>Kent<br><br>_______________________________________________<br>Tutor maillist -
<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br>