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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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