Q:

Overly complex list comprehension? 

I have a list of objects with an attribute called mgmt_classes that is itself a list.  
systems = [System, System, System,...]
System.mgmt_classes = ['foo','bar']

I want to identify the System objects within the systems list that have a mgmt_class named 'foo'.  I came up with two ways to do that, but I don't like either one. 
Ugly list comprehension
matching = [system for system in systems 
            if len([mc for mc in system.mgmt_classes 
                    if re.search(search, mc)]) > 0]

Ugly nested loops
matching = []
for system in systems:
    for mgmt_class in system.mgmt_classes:
        if re.search(search, mgmt_class):
            matching.append(system)

I don't like either one of them.  Is there a more elegant way of doing this?  My gut is telling me that the ugly nested loops would be the better solution of the two since it's easier to follow. 
Edit:
I want to be able to search for partial terms in mgmt_classes, so 'foo' would get me 'food' or 'football' for example. 

A:

If your matching criteria is sophisticated, consider factoring it out into another function like:
systems = [System, System, System,...]
System.mgmt_classes = ['foo','bar']

def hasmatches(classes):
    return any(re.search(search, mc) for mc in classes)

matching = [system for system in systems
    if hasmatches(system.mgmt_classes)]

hasmatches returns True the first time it finds a match in the list of classes, or else False if none of them match.  Then the list comprehension calls it on each system and collects the ones where hasmatches evaluates to True. 
If it's really as simple as looking for a specific value, lose the regular expressions in favor of direct string comparisons:
matching = [system for system in systems if 'foo' in system.mgmt_classes]

A:

matching = [system for system in systems if 'foo' in system.mgmt_classes]

The if statement checks if 'foo' is in the attribute mgmt_classes - much simpler than using regular expressions. 
However if your condition requires using regular expressions, use this:
matching = [system for system in systems if any(re.search('foo', i) for i in system.mgmt_classes)]

This is simply a oneliner version of Kirk's answer.