Danke für Eure schnellen Antworten!
Leonidas hat geschrieben:acidk hat geschrieben:und das Wichtigste: kann ich LISTEN pickeln (kenne das nur von strings) o.ä. um sie aus dem Ram zu bekommen?
Schon mal ausprobiert?
Achja, Tuples sind speicherschonender als Listen, da ihre Länge feststeht und sie nicht überalloziiert sind.
Ich hab mich mal mit dem Pickeln (okay - nicht lustig)

versucht:
Beispiel von hier:
http://docs.python.org/library/pickle.h ... ule-pickle
i
Code: Alles auswählen
mport pickle
data1 = {'a': [1, 2.0, 3, 4+6j],
'b': ('string', u'Unicode string'),
'c': None}
selfref_list = [1, 2, 3]
selfref_list.append(selfref_list)
output = open('data.pkl', 'wb')
# Pickle dictionary using protocol 0.
pickle.dump(data1, output)
# Pickle the list using the highest protocol available.
pickle.dump(selfref_list, output, -1)
output.close()
Die Error Meldung sieht folgendermassen aus:
flo@AKB-34:~/Desktop/grid_analysis$ python pickle.py
Traceback (most recent call last):
File "pickle.py", line 4, in <module>
import pickle
File "/home/flo/Desktop/grid_analysis/pickle.py", line 16, in <module>
pickle.dump(data1, output)
AttributeError: 'module' object has no attribute 'dump'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/apport_python_hook.py", line 38, in apport_excepthook
from apport.packaging_impl import impl as packaging
File "/usr/lib/python2.5/site-packages/apport/__init__.py", line 1, in <module>
from apport.report import Report
File "/usr/lib/python2.5/site-packages/apport/report.py", line 14, in <module>
import subprocess, tempfile, os.path, urllib, re, pwd, grp, os, sys
File "/usr/lib/python2.5/subprocess.py", line 404, in <module>
import pickle
File "/home/flo/Desktop/grid_analysis/pickle.py", line 16, in <module>
pickle.dump(data1, output)
AttributeError: 'module' object has no attribute 'dump'
Original exception was:
Traceback (most recent call last):
File "pickle.py", line 4, in <module>
import pickle
File "/home/flo/Desktop/grid_analysis/pickle.py", line 16, in <module>
pickle.dump(data1, output)
AttributeError: 'module' object has no attribute 'dump'
Finde ich sehr merkwürdig -- habe ich irgendetwas übersehen / nicht importiert?
Ich benutze Ubuntu 8.10 -- aber das spielt wohl eher eine untergeordnete Rolle bei der Fehlersuche....