Pb with an AttributeError

Eric BOUVIER ebouvier at jetmultimedia.fr
Thu Sep 27 11:03:02 EDT 2007


Hello,

First, sorry for my english.

I've just been assigned a project written in Python which contains
bug(s).
I've never programmed in Python, but I've read the code  
and understood basically what the different source codes do.

I've traced the code and found where the problem is but I don't 
know how to solve the problem.

Here it is :

I've got a string issued from a CSV file : 
   string1 = eval(line[4])
   print " * string1 = (", string1 ,") \n"      
        =>  * string1 = ( {'header': 'X-Score', 'param': {'key':
'SP<136>=', 'value': ['SD:<0> ']} )

Then, there is a split with the equal : 
   TheParts = string.split(string1["param"], "=")
   print " * TheParts = (", TheParts ,") \n"

But, running the program returns : 

Traceback (most recent call last):
  File "C:\test\helper.py", line 136, in Action_handler
    Score_eval(line, OutputFile_SP, This_Host)
  File "C:\test\helper.py", line 66, in Score_eval
    TheParts = string.split(string1["param"], "=")
  File "C:\ActiveState\Python25\lib\string.py", line 290, in split
    return s.split(sep, maxsplit)
AttributeError: 'dict' object has no attribute 'split'  !?!

I've found that it works when I put directly the string in the split
expression : 

   TheParts = string.split(" {'key': 'ESP<136>=', 'value': ['SHA:<0> ']}
", "=")
      => * TheParts =   ["{'key': 'ESP<136>", "', 'value': ['SHA:<0>
']}"]

  But the code isn't dynamic anymore !
I think it's a problem with the type, but the different syntax I've
tried didn't work.
Is somebody could help me ?

 Thank you

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070927/ce3ed8b9/attachment.html>


More information about the Python-list mailing list