Strings --> Dictionaries 
Author Message
 Strings --> Dictionaries

I seems like I once saw a technique for converting specially formatted
strings directly into dictionaries.  ie:

string = "{CATEGORY: value}
dictionary = string.toDict ()  (Of course, that is made up.)

Unfortunately I can now not find this info.  Was I imagening things?  If
not, how is it done?

Thanks much in advance!

--W. Michael Petullo
  Senior System Administrator, digimecca.net

This message was brought to you in part by the Linux operating system.



Mon, 13 Dec 1999 03:00:00 GMT  
 Strings --> Dictionaries

Quote:
> I seems like I once saw a technique for converting specially formatted
> strings directly into dictionaries.  ie:

> string = "{CATEGORY: value}
> dictionary = string.toDict ()  (Of course, that is made up.)

You can use the eval statement which transforms strings to python objects.
Don't forget to quote substrings that are to appear as strings in the python
object. Thus, e.g.:

        dictionary = eval( "{'a': 1, 'b': 2}" )

cjr

--



Wed, 15 Dec 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Dictionary to string and back to dictionary??

2. question about symbol->string, string->list

3. string->list->string

4. Dictionary>>addAll:

5. Was Re: Dictionary>>addAll:

6. Problems and Dictionary>>copy-Bug in VW3 and VW7

7. Collection>>addAll: problems on Dictionaries

8. Output to strings / F>STRING

9. Proposal: S>UPPER etc /was: Standardising string primitives (was: Re: String)

10. MIT scheme: string->list on long strings

11. External interfacing to varargs, and String>>sprintfWithArguments:

12. Bug on String>>replaceAll:with:

 

 
Powered by phpBB® Forum Software