Skip to content

Instantly share code, notes, and snippets.

@alexey-goloburdin
Last active August 28, 2019 12:48
Show Gist options
  • Save alexey-goloburdin/18c82fd011379a83a70aae739d0296d9 to your computer and use it in GitHub Desktop.
Save alexey-goloburdin/18c82fd011379a83a70aae739d0296d9 to your computer and use it in GitHub Desktop.
Пример сериализации именованных кортежей
import pickle
from collections import namedtuple
keys = [["tmp"], ["tmp1", "tmp2"]]
values = [[1], [2, 3]]
s = []
for index, (k, v) in enumerate(zip(keys, values)):
globals()[f"cls{index}"] = namedtuple(f"cls{index}", k)
s.append(globals()[f"cls{index}"](*v))
pickle.dumps(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment