Skip to main content

Serialization/deserialization of iterables of type 'str' to a single string.

Project description

iterable-serialization

Serialization/deserialization of iterables of type str.

This package aims to be a better version of:

serialized = "|".join(("a", "b", "c"))
print(serialized)
# a|b|c

deserialized = serialized.split("|")
print(deserialized)
# ['a', 'b', 'c']

It makes it possible to serialize/deserialize an iterable with occurring symbols as separator:

serialized = serialize_iterable(("a", "b", "c"), "a")
print(serialized)
# aabac

deserialized = deserialize_iterable(serialized, "a")
print(list(deserialized))
# ['a', 'b', 'c']

With the version above, it would result in a wrong deserialization result:

serialized = "a".join(("a", "b", "c"))
print(serialized)
# aabac

deserialized = serialized.split("a")
print(list(deserialized))
# ['', '', 'b', 'c']

Installation

pipenv install -e git+https://github.com/stefantaubert/iterable-serialization.git@master#egg=iterable_serialization

Usage

from iterable_serialization import deserialize_iterable, serialize_iterable

serialized = serialize_iterable(("a", "b", "c"), "a")
print(serialized)
# aabac

deserialized = deserialize_iterable(serialized, "a")
print(list(deserialized))
# ['a', 'b', 'c']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iterable-serialization-0.0.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

iterable_serialization-0.0.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file iterable-serialization-0.0.1.tar.gz.

File metadata

File hashes

Hashes for iterable-serialization-0.0.1.tar.gz
Algorithm Hash digest
SHA256 29dd698e6537fde4361a2ba360ec98b4922003f4c177fd4d5db75fa78e087386
MD5 34478f817eed9bbe8bbeebd0645e07d5
BLAKE2b-256 e224c97e6f2470e072596a11036a151b2e34079a43f1468236d143a6226ffcc4

See more details on using hashes here.

File details

Details for the file iterable_serialization-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for iterable_serialization-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bfe3eb07287085a3051235c5b4acd0daa98b4af8c97c66b1395ecb849ea2eb38
MD5 72a557b97ada2632bba65a73a91ca33e
BLAKE2b-256 95f99bb5fa5db4756fa9a4408da072fdaaaae86e0ac52cd71b6cca3f857efb46

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page