Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To do this, I'd not do anything complicated... I'd write the code you wanted to write. I'd use <a href="http://pythonhosted.org/dill" rel="nofollow">dill</a>, which can serialize almost anything in python.</p> <pre><code>&gt;&gt;&gt; import dill &gt;&gt;&gt; import datetime &gt;&gt;&gt; a = [datetime.datetime(2012, 2, 1), datetime.datetime(2012, 2, 2), 'string', 4.00] &gt;&gt;&gt; b = [datetime.datetime(2012, 3, 1), datetime.datetime(2012, 3, 4), 'another_string', 5.00] &gt;&gt;&gt; &gt;&gt;&gt; list_of_lists = [a,b] &gt;&gt;&gt; &gt;&gt;&gt; lol = dill.loads(dill.dumps(list_of_lists)) &gt;&gt;&gt; lol [[datetime.datetime(2012, 2, 1, 0, 0), datetime.datetime(2012, 2, 2, 0, 0), 'string', 4.0], [datetime.datetime(2012, 3, 1, 0, 0), datetime.datetime(2012, 3, 4, 0, 0), 'another_string', 5.0]] &gt;&gt;&gt; &gt;&gt;&gt; default_date = datetime.datetime.today() &gt;&gt;&gt; &gt;&gt;&gt; def analyze_data(some_id, some_date=default_date): ... string_date = some_date.strftime('%Y%m%d') ... filename = '{0}_{1}.p'.format(some_id, string_date) ... return dill.loads(dill.dumps(list_of_lists)) ... &gt;&gt;&gt; # no kaboom &gt;&gt;&gt; analyze_data('123') [[datetime.datetime(2012, 2, 1, 0, 0), datetime.datetime(2012, 2, 2, 0, 0), 'string', 4.0], [datetime.datetime(2012, 3, 1, 0, 0), datetime.datetime(2012, 3, 4, 0, 0), 'another_string', 5.0]] </code></pre> <p>Dill also has <a href="https://github.com/uqfoundation/dill/blob/master/dill/detect.py" rel="nofollow">some good tools</a> for helping you understand what is causing your pickling to fail when your code fails.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload