Skip to main content

collections.defaultdict equivalent implementation of list.

Project description

https://badge.fury.io/py/defaultlist.svg https://travis-ci.org/c0fec0de/defaultlist.svg?branch=master https://coveralls.io/repos/github/c0fec0de/defaultlist/badge.svg https://readthedocs.org/projects/defaultlist/badge/?version=1.0.0 https://codeclimate.com/github/c0fec0de/defaultlist.png https://img.shields.io/pypi/pyversions/defaultlist.svg https://landscape.io/github/c0fec0de/defaultlist/master/landscape.svg?style=flat

Documentation

The Documentation is hosted on http://defaultlist.readthedocs.io/en/1.0.0/

Getting started

List extending automatically to the maximum requested length.

Added indicies are filled with None by default.

>>> from defaultlist import defaultlist
>>> l = defaultlist()
>>> l
[]
>>> l[2] = "C"
>>> l
[None, None, 'C']
>>> l[4]
>>> l
[None, None, 'C', None, None]

Slices and negative indicies are supported likewise

>>> l[1:4]
[None, 'C', None]
>>> l[-3]
'C'

Simple factory functions can be created via lambda.

>>> l = defaultlist(lambda: 'empty')
>>> l[2] = "C"
>>> l[4]
'empty'
>>> l
['empty', 'empty', 'C', 'empty', 'empty']

Installation

To install the defaultlist module run:

pip install defaultlist

If you do not have write-permissions to the python installation, try:

pip install defaultlist --user

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

defaultlist-1.0.0.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file defaultlist-1.0.0.tar.gz.

File metadata

  • Download URL: defaultlist-1.0.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for defaultlist-1.0.0.tar.gz
Algorithm Hash digest
SHA256 58cec08e2b1bd8a1a39e7a78dbbf6f66250258f461eb9b9ac0cc3eb78d3a0aca
MD5 4728e6caf3c36586fe0560dfa8c28c52
BLAKE2b-256 b2e6cf788a63ef0dcf7f352bfdd917dd51b1f59b51ff39b28b93a003e4d4ba4e

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