Too big of a list? and other problems

Ben Finney bignose+hates-spam at benfinney.id.au
Mon May 22 20:48:32 EDT 2006


"Brian" <bnblazer at gmail.com> writes:

> First off, I am sorry for cluttering this group with my inept
> questions

Questions aren't a problem; we all come here to learn at some point.

I will ask you, though, to learn effective quoting when you respond to
someone's post (i.e. quote relevant material that gives some context
to your response, with your response following).

> I have a function (below) that takes a list of html pages that have
> images on them (not porn but boats).

Not boat porn? :-)

> When I looked at it while running, it appears as if my regex is
> actually appending a tuple (I think) of the results it finds to the
> list.

Yes, that's what you asked it to do.

>         pics = re.compile(r"images/.*\.jpeg")
>         foundPics.append(pics.findall(html))

The 'findall' method of a regex object acts like the module's
'findall' function; it returns a list of the matches.

    <URL:http://docs.python.org/lib/node115.html#l2h-879>

The 'append' method of a list object appends a single value to a
list. You're appending a list value to a list, extending it by one
value (the list of matches).

Perhaps you want the 'extend' method, which will append each item in
the specified sequence, extend the existing list by the values from
that sequence.

    <URL:http://docs.python.org/lib/typesseq-mutable.html>

-- 
 \       "Yesterday I told a chicken to cross the road. It said, 'What |
  `\                                          for?'"  -- Steven Wright |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list