{"id":47870064,"url":"https://github.com/o3bvv/lazy-string","last_synced_at":"2026-04-04T00:47:32.615Z","repository":{"id":57438568,"uuid":"313678725","full_name":"o3bvv/lazy-string","owner":"o3bvv","description":"Python library for defining strings with delayed evaluation","archived":false,"fork":false,"pushed_at":"2020-11-17T21:45:44.000Z","size":6,"stargazers_count":11,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-04T00:47:29.513Z","etag":null,"topics":["lazy","lazy-evaluation","libraries","library","python","string","strings"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/lazy-string","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/o3bvv.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-17T16:31:29.000Z","updated_at":"2026-02-24T10:00:00.000Z","dependencies_parsed_at":"2022-09-08T08:00:55.731Z","dependency_job_id":null,"html_url":"https://github.com/o3bvv/lazy-string","commit_stats":null,"previous_names":["oblalex/lazy-string"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/o3bvv/lazy-string","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/o3bvv%2Flazy-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/o3bvv%2Flazy-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/o3bvv%2Flazy-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/o3bvv%2Flazy-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/o3bvv","download_url":"https://codeload.github.com/o3bvv/lazy-string/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/o3bvv%2Flazy-string/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31383635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T23:20:52.058Z","status":"ssl_error","status_checked_at":"2026-04-03T23:20:51.675Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lazy","lazy-evaluation","libraries","library","python","string","strings"],"created_at":"2026-04-04T00:47:31.276Z","updated_at":"2026-04-04T00:47:32.590Z","avatar_url":"https://github.com/o3bvv.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"lazy-string\n===========\n\nPython library for defining strings with delayed evaluation.\n\n|pypi_package| |python_versions| |license|\n\n\nThe package provides a ``LazyString`` class. Its constructor accepts a callable (say, a function) which will be called when string's value is needed. The constructor also allows to specify positional and keyword arguments for that callable:\n\n.. code-block:: python\n\n  def __init__(self, func: Callable[..., str], *args: Tuple, **kwargs: Mapping) -\u003e None:\n    ...\n\n\nThe value is re-evaluated on every access.\n\n\nInstallation\n------------\n\nAvailable as a `PyPI \u003chttps://pypi.python.org/pypi/lazy-string\u003e`_ package:\n\n.. code-block:: bash\n\n  pip install lazy-string\n\n\nUsage\n-----\n\nUsing with a function having no parameters:\n\n.. code-block:: python\n\n  from lazy_string import LazyString\n\n  def make_foo() -\u003e str:\n    return \"foo\"\n\n  s = LazyString(make_foo)\n\n\nThe value is evaluated on demand:\n\n.. code-block:: python\n\n  \u003e\u003e\u003e s + \" bar\"\n  'foo bar'\n\n  \u003e\u003e\u003e str(s)\n  'foo'\n\n\nRepresentation explicitly tells it's a ``LazyString``:\n\n.. code-block:: python\n\n  \u003e\u003e\u003e s\n  LazyString('foo')\n\n\nIt's safe to pass standard strings, as they will be returned as-is:\n\n.. code-block:: python\n\n  \u003e\u003e\u003e LazyString(\"foo bar\")\n  'foo bar'\n\n\nSupports methods of standard strings:\n\n.. code-block:: python\n\n  \u003e\u003e\u003e s.upper()\n  'FOO'\n\n  \u003e\u003e\u003e \"f\" in s\n  True\n\n  \u003e\u003e\u003e dir(s)\n  ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__',\n   '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__',\n   '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__',\n   '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__',\n   '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__',\n   '__setattr__', '__sizeof__', '__str__', '__subclasshook__',\n   'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith',\n   'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha',\n   'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric',\n   'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower',\n   'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust',\n   'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith',\n   'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']\n\n\nSupplying parameters for the callable:\n\n.. code-block:: python\n\n  def make_foo(arg1, arg2):\n    return f\"foo {arg1} {arg2}\"\n\n  s = LazyString(make_foo, 123, arg2=456)\n\n\n.. code-block:: python\n\n  \u003e\u003e\u003e str(s)\n  'foo 123 456'\n\n\nImplementation Details\n----------------------\n\n``LazyString`` is inherited from `collections.UserString \u003chttps://docs.python.org/3/library/collections.html#collections.UserString\u003e`_.\n\n.. code-block:: python\n\n  \u003e\u003e\u003e LazyString.__mro__\n  (\u003cclass 'lazy_string.LazyString'\u003e, \u003cclass 'collections.UserString'\u003e,\n   \u003cclass 'collections.abc.Sequence'\u003e, \u003cclass 'collections.abc.Reversible'\u003e,\n   \u003cclass 'collections.abc.Collection'\u003e, \u003cclass 'collections.abc.Sized'\u003e,\n   \u003cclass 'collections.abc.Iterable'\u003e, \u003cclass 'collections.abc.Container'\u003e,\n   \u003cclass 'object'\u003e)\n\n\nSerialization\n-------------\n\nPickling\n^^^^^^^^\n\nSupported out of the box:\n\n.. code-block:: python\n\n  \u003e\u003e\u003e import pickle\n  \u003e\u003e\u003e s == pickle.loads(pickle.dumps(s))\n  True\n\n\nTo JSON\n^^^^^^^\n\nSupported with any encoder able to encode ``collections.UserString``:\n\n.. code-block:: python\n\n  import json\n  import collections\n\n  class JSONEncoder(json.JSONEncoder):\n\n    def default(self, o):\n      if isinstance(o, collections.UserString):\n        return str(o)\n      return super().default(o)\n\n\n.. code-block:: python\n\n  \u003e\u003e\u003e data = {'s': s}\n  \u003e\u003e\u003e json.dumps(data, cls=JSONEncoder)\n  '{\"s\": \"foo\"}'\n\n\n.. |pypi_package| image:: https://img.shields.io/pypi/v/lazy-string\n   :target: http://badge.fury.io/py/lazy-string/\n   :alt: Version of PyPI package\n\n.. |python_versions| image:: https://img.shields.io/badge/Python-3.7+-brightgreen.svg\n   :alt: Supported versions of Python\n\n.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg\n   :target: https://github.com/oblalex/lazy-string/blob/main/LICENSE\n   :alt: MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fo3bvv%2Flazy-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fo3bvv%2Flazy-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fo3bvv%2Flazy-string/lists"}