The Opposite of list(a,b,c)?

Bjorn Pettersen bjorn at roguewave.com
Fri Apr 14 20:10:23 EDT 2000


"Andrew P. Jewell" wrote:
> 
> Can someone please tell me the opposite of list("A", "b", "string")?
>  Or maybe there's a smarter way to do what I'm trying to do.  I have a
> dictionary that looks like this:
> 
>     dtnA["key1"] = [val1, val2]
>     dtnA["key2"] = [val3, val4]
>     dtnA["key3"] = [val5, val6]
> 
> I want to do something like this:
> 
> def func(SearchTerm):
>   <...>
>     retval = []
>     for keyval in (dtnA.keys()):
>         mtch = re.search(patSrchTrm, keyval)
>         if mtch:
>             retval.append(UNLIST(dtnA[keyval]))

retval = reval + UNLIST(dtnA[keyval])

-bjorn

> 
> I want to end up with just a list of matching values from the
> dictionary, ala:
>     ['val1, val2', 'val3, val4']
> 
> But I can only get a list of lists: [[val1,val2],[val3,val4]] - which
> makes perfect sense based on how I'm doing it - but I don't WANT a
> list of lists!  Is there anyway to do this?  I don't really want to
> tuple-ize my dictionary since it's attached to its list values in
> other ways.  It seems ugly to have to iterate my dictionary value list
> to UN-list them manually - and the repr deal is REALLY ugly. What am I
> missing??  Thanks for any help!
> 
> Andy
> 
>   -- http://www.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list