Last active
August 28, 2019 12:48
-
-
Save alexey-goloburdin/18c82fd011379a83a70aae739d0296d9 to your computer and use it in GitHub Desktop.
Пример сериализации именованных кортежей
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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