Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import print_function
- import collections
- import jsonpickle
- import yaml
- import pickle
- import bson
- def dumpme(item):
- print("item is:", item)
- y = yaml.dump(item)
- print("yaml is: ", y)
- assert item==yaml.load(y)
- p = pickle.dumps(item)
- print("pickle is: ", p)
- assert item==pickle.loads(p)
- j = jsonpickle.encode(item)
- print("jsonpickle:", j)
- decoded = jsonpickle.decode(j)
- print("decoded is:", decoded)
- assert item==jsonpickle.decode(j)
- def main():
- x = collections.defaultdict(list)
- x['foo'].append('bar')
- x['car'] = [3, 5, 'twelve']
- y = dict(foo=x,
- mydeque=collections.deque((8, 2, 'noon')))
- dumpme(y)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment