Adding items to dictionary if condition is true, else dont - python
        Posted  
        
            by 
                CodeTalk
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by CodeTalk
        
        
        
        Published on 2014-05-28T15:19:44Z
        Indexed on 
            2014/05/28
            15:24 UTC
        
        
        Read the original article
        Hit count: 254
        
I'm trying to take an existing process:
if self.path_object is not None:
    dictpath = {}
    for path in self.path_object:
        self.params = path.pathval.split("?")[0]
        self.params = path.pathval.split("&", 2)
        if path.pathval.contains(self.params):
            out = list(map(lambda v: v.split("=")[0] +"=" + str(self.fuzz_vectors), self.params))
        else:
            pass
        dictpath[path] = out
    print dictpath
I added the sub-if/else block in, but it is failing, stating:
AttributeError: 'unicode' object has no attribute 'contains'
on the if block .
How can I fix it?
I'm simply trying to do:
if the path.pathval has either ? or & in it:
   add to dictionary
else:
    pass #forget about it.
Thanks!
© Stack Overflow or respective owner