Top-rated recipes tagged "pickle"http://code.activestate.com/recipes/tags/pickle/top/2016-06-29T20:09:44-07:00ActiveState Code RecipesMixin for pickling objects with __slots__ (Python) 2013-01-21T08:55:57-08:00Oren Tiroshhttp://code.activestate.com/recipes/users/2033964/http://code.activestate.com/recipes/578433-mixin-for-pickling-objects-with-__slots__/ <p style="color: grey"> Python recipe 578433 by <a href="/recipes/users/2033964/">Oren Tirosh</a> (<a href="/recipes/tags/pickle/">pickle</a>, <a href="/recipes/tags/unpickle/">unpickle</a>, <a href="/recipes/tags/__slots__/">__slots__</a>). </p> <p>This mixin makes it possible to pickle/unpickle objects with __slots__ defined. </p> Serialize and Deserialize Securely (Python) 2009-11-04T19:57:41-08:00Eric Pruitthttp://code.activestate.com/recipes/users/4170757/http://code.activestate.com/recipes/576943-serialize-and-deserialize-securely/ <p style="color: grey"> Python recipe 576943 by <a href="/recipes/users/4170757/">Eric Pruitt</a> (<a href="/recipes/tags/cpickle/">cpickle</a>, <a href="/recipes/tags/pickle/">pickle</a>, <a href="/recipes/tags/serialize/">serialize</a>). Revision 19. </p> <p>A serialization library to serialize some of the more basic types. Does not suffer from the security flaws that cPickle and pickle do.</p> convert hierarchy of data files into a convenient Python dictionary (Python) 2016-06-29T20:09:44-07:00Brian Fiedlerhttp://code.activestate.com/recipes/users/4194196/http://code.activestate.com/recipes/580687-convert-hierarchy-of-data-files-into-a-convenient-/ <p style="color: grey"> Python recipe 580687 by <a href="/recipes/users/4194196/">Brian Fiedler</a> (<a href="/recipes/tags/pickle/">pickle</a>). Revision 2. </p> <p>Converts the CRUTEM text data files into a convenient Python dictionary. The data files are at: <a href="http://www.metoffice.gov.uk/hadobs/crutem4/data/station_files/CRUTEM.4.4.0.0.station_files.zip" rel="nofollow">http://www.metoffice.gov.uk/hadobs/crutem4/data/station_files/CRUTEM.4.4.0.0.station_files.zip</a></p> Save and restore SHA-512 internal state (Python) 2013-03-03T18:05:42-08:00Dima Tisnekhttp://code.activestate.com/recipes/users/4068698/http://code.activestate.com/recipes/578479-save-and-restore-sha-512-internal-state/ <p style="color: grey"> Python recipe 578479 by <a href="/recipes/users/4068698/">Dima Tisnek</a> (<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/inner/">inner</a>, <a href="/recipes/tags/pickle/">pickle</a>, <a href="/recipes/tags/restore/">restore</a>, <a href="/recipes/tags/sha512/">sha512</a>, <a href="/recipes/tags/state/">state</a>). </p> <p>If you have a very long input to hash, you may want to save your progress.</p> <p>CPython doesn't normally let you, but it's easy to hack around via ctypes</p> Random user generator (Python) 2012-02-27T16:58:33-08:00Koppula Varun Rajhttp://code.activestate.com/recipes/users/4181072/http://code.activestate.com/recipes/578055-random-user-generator/ <p style="color: grey"> Python recipe 578055 by <a href="/recipes/users/4181072/">Koppula Varun Raj</a> (<a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/pickle/">pickle</a>, <a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/random/">random</a>). </p> <p>I've worked on a random user generator in C a long time ago, so I thought I'd make an advanced version of it in Python(3.2). I'll have you know, I am an amateur in Python and even programming for that matter so I'd really appreciate some criticism on my code and what more can be added.</p> <p>About the program - I've added a default list of users, you can modify the list to your convenience and for data persistence, I made use of the pickle module. The random module plays the pivotal role generating the output making use of the choice method. Those along with the os module if the program is being run for the first time on a pc, it will create a data file with the default list.After some digging around, I managed to find os.getlogin() from the python library which was exactly what I was looking for (to get the computer's name making sure it can get the data file to the correct directory). I'm a little skeptical about that part, wondering whether or not it will work on every pc.</p> JSON instead of pickle for memcached (Python) 2012-01-10T22:31:36-08:00pavelhttp://code.activestate.com/recipes/users/4171837/http://code.activestate.com/recipes/578011-json-instead-of-pickle-for-memcached/ <p style="color: grey"> Python recipe 578011 by <a href="/recipes/users/4171837/">pavel</a> (<a href="/recipes/tags/cache/">cache</a>, <a href="/recipes/tags/json/">json</a>, <a href="/recipes/tags/memcache/">memcache</a>, <a href="/recipes/tags/memcached/">memcached</a>, <a href="/recipes/tags/pickle/">pickle</a>). </p> <p>Standard memcache client uses pickle as a serialization format. It can be handy to use json, especially when another component (e.g. backend) does'n know pickle, but json yes.</p> Pickle to/from socket (Python) 2011-04-19T22:22:53-07:00pavelhttp://code.activestate.com/recipes/users/4171837/http://code.activestate.com/recipes/577667-pickle-tofrom-socket/ <p style="color: grey"> Python recipe 577667 by <a href="/recipes/users/4171837/">pavel</a> (<a href="/recipes/tags/pickle/">pickle</a>, <a href="/recipes/tags/socket/">socket</a>). Revision 2. </p> <p>It's useful for transfering objects through socket, when doing communication between processes or networking.</p> SyncFiles (Python) 2008-12-13T21:28:57-08:00Collin Stockshttp://code.activestate.com/recipes/users/4149235/http://code.activestate.com/recipes/576584-syncfiles/ <p style="color: grey"> Python recipe 576584 by <a href="/recipes/users/4149235/">Collin Stocks</a> (<a href="/recipes/tags/backup/">backup</a>, <a href="/recipes/tags/consistency/">consistency</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/gnu/">gnu</a>, <a href="/recipes/tags/gpl/">gpl</a>, <a href="/recipes/tags/just_in_case/">just_in_case</a>, <a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/pickle/">pickle</a>, <a href="/recipes/tags/state_machine/">state_machine</a>, <a href="/recipes/tags/storage/">storage</a>, <a href="/recipes/tags/sync/">sync</a>, <a href="/recipes/tags/synchronize/">synchronize</a>). Revision 3. </p> <p>This module allows you to handle and protect from inconsistencies sets of files that must all be saved at the same time. It does this be creating backups and temporary files. It has been moderately tested for bugs.</p>