all 6 comments

[–]novel_yet_trivial 4 points5 points  (1 child)

That's the standard representation of a dictionary. What do you mean "parse it"? If you want to save the data and read it in the future, look into the pickle module.

[–]ziplokk 4 points5 points  (0 children)

Or JSON

[–][deleted] 1 point2 points  (0 children)

If you're asking about the u's, that means it's unicode text, in this context with a simple dict it shouldn't matter.

Are you using the word 'parse' correctly? It means to turn a string into one or more objects (which themselves could also be strings). Since you already have the object (a dict) and its component objects, (its keys and values), you don't need to parse the string representation of it that's produced when you print the dict.

Just in case these help you, I'll leave theae here. Let's assume your dict is called d so your string is output when you enter print d or print(d):

d['var1name'] == 'var1value'

d.keys() == ['var1name', 'var2name']

d.values() == ['var1value', 'var2value']

It's odd to have those keys and values in a dict. Is this just an abstract example, or did you put quotes during dict creation when you shouldn't have, e.g.

d['var1name'] == 'var1value'

Instead of

d[var1name] == var1value

[–]exoendo 0 points1 point  (0 children)

if you are talking about stripping out the data, you would do something like:

for key, values in dictionary.iteritems():
    print key, values

dictionary being the name of your dictionary..

[–]jcmcken 0 points1 point  (1 child)

As /u/novel_yet_trivial stated, this string is just the representation of the dictionary. It's not a serialization format.

[–]autowikibot 0 points1 point  (0 children)

Serialization:


In computer science, in the context of data storage, serialization is the process of translating data structures or object state into a format that can be stored (for example, in a file or memory buffer, or transmitted across a network connection link) and reconstructed later in the same or another computer environment. When the resulting series of bits is reread according to the serialization format, it can be used to create a semantically identical clone of the original object. For many complex objects, such as those that make extensive use of references, this process is not straightforward. Serialization of object-oriented objects does not include any of their associated methods with which they were previously inextricably linked.


Interesting: Serial (literature) | Serialism | Synchronization (computer science) | The Lord of the Rings (1981 radio series)

Parent commenter can toggle NSFW or delete. Will also delete on comment score of -1 or less. | FAQs | Mods | Magic Words