The Opposite of list(a,b,c)?
Thomas Wouters
thomas at xs4all.net
Sat Apr 15 05:01:24 EDT 2000
On Fri, Apr 14, 2000 at 05:04:47PM -0700, Daniel Berlin wrote:
> <snip>
> > def func(SearchTerm):
> > <...>
> > retval = []
> > for keyval in (dtnA.keys()):
> > mtch = re.search(patSrchTrm, keyval)
> > if mtch:
> > retval.append(UNLIST(dtnA[keyval]))
> Change this to:
> if mtch:
> for value in dtnA[keyval]:
> retval.append(value)
Dont forget 'extend':
>>> spam = ['spam', 'spam', 'spam', 'spam and eggs']
>>> toast = ['spam and toast', 'toast, eggs and spam', 'eggs, spam and bacon']
>>> spam.extend(toast)
>>> spam
['spam', 'spam', 'spam', 'spam and eggs', 'spam and toast', 'toast, eggs and
spam', 'eggs, spam and bacon']
'spam + toast' works the same, but creates a new list. extend() works as the
for loop above, appending each element of the 2nd list to the first,
in-place.
--
Thomas Wouters <thomas at xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
More information about the Python-list
mailing list