tags:

views:

147

answers:

1

Hi,

I'm trying to write a little script to clean my directories. In fact I have:

pattern = re.compile(format[i])
...
current_f.append(pattern.search(str(ls)))

and I want to use a list comprehension but when I try:

In [25]: [i for i in current_f.group(0)]

I get:

AttributeError: 'list' object has no attribute 'group'

So how to make a list comprehension using group()? Is there another way to do what I want.

Thanks in advance.

+7  A: 

Are you trying to do this?:

[f.group(0) for f in current_f]
sth