<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi all,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I am having problems with the apply function in 
Python.  When applying a string variable to a method, the string var gets 
chopped up into all it chars and each char gets sent as a parameter!  The 
result is getting a TypeError because I am sending too much parameters to the 
function (more detail below if you still don't understand)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Regards</FONT></DIV>
<DIV><FONT face=Arial size=2>Etienne</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Detailed explanation:</FONT></DIV>
<DIV><FONT face=Arial size=2>When running my program I get the 
following:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>My print line debugging string 
output:<BR>Formatting value '20020625140609' of type <type 'string' with 
formatter <function TimeFormatter at 00D613F4></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>as you can see, I am sending the string 
'20020625140609' to the function TimeFormatter.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The code that does this is:</FONT></DIV>
<DIV><FONT face=Arial size=2>print "UCP: Formatting value '%s' of type '%s' with 
formatter '%s'" %(value, type(value), formatter)<BR>value = 
apply(formatter,(str(value)))</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>in this case, formatter is the function 
TimeFormatter (as defined in a mapping table)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>When this code executes I get a 
TypeError:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>TypeError: TimeFormatter() takes exactly 1 argument 
(14 given).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Why is the string (which is 14 chars long) broken 
up into 14 values when passed using apply!?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The weird thing is this code has been working for 
MONTHS and have only recently stopped working after some refactoring in a 
completely different part of code!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The problem goes away when I don't use 
apply:<BR>value = formatter(value)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>