Skip to main content

identicallist

A mutable Python list that allows only identical objects and inherits their properties and methods.

If a list property changes, it changes this property in all items. If a list method is invoked, it invokes the method on all items.

Examples

IdenticalList behaves just like a list:

from identicallist import IdenticalList


class DummyItem:
    def __init__(self):
        self.num = 5

    def inc(self):
        self.num += 1

    def dec(self):
        self.num -= 1


il = IdenticalList(DummyItem(), DummyItem())
print(len(il)) # 2
print(iter(il)) # <generator object Sequence.__iter__ at 0x7fc3b708d5d0>
for i, item in enumerate(il):
    print('item number {} has the attribute num with value {}'.format(i, item.num))
# item number 0 has the attribute num with value 5
# item number 1 has the attribute num with value 5

At the same time, it also behaves like the first object of the list:

print(il.num) # 5
il.inc()
print(il.num) # 6

Changing properties and calling methods on the list object affects all items in the list:

for i, item in enumerate(il):
    print('item number {} has the attribute num with value {}'.format(i, item.num))
# item number 0 has the attribute num with value 6
# item number 1 has the attribute num with value 6
il.dec()
il.dec()
print(il.num) # 4
for i, item in enumerate(il):
    print('item number {} has the attribute num with value {}'.format(i, item.num))
# item number 0 has the attribute num with value 4
# item number 1 has the attribute num with value 4
il.num = 7
for i, item in enumerate(il):
    print('item number {} has the attribute num with value {}'.format(i, item.num))
# item number 0 has the attribute num with value 7
# item number 1 has the attribute num with value 7

Changing properties on individual items in the list only affect that item:

il[1].num = 8
for i, item in enumerate(il):
    print('item number {} has the attribute num with value {}'.format(i, item.num))
# item number 0 has the attribute num with value 7
# item number 1 has the attribute num with value 8
il[0].dec()
for i, item in enumerate(il):
    print('item number {} has the attribute num with value {}'.format(i, item.num))
# item number 0 has the attribute num with value 6
# item number 1 has the attribute num with value 8

Now, calling inc on the list increases all item's num property. Note that because they started with different values, the resulting values are still different:

il.inc()
for i, item in enumerate(il):
    print('item number {} has the attribute num with value {}'.format(i, item.num))
# item number 0 has the attribute num with value 7
# item number 1 has the attribute num with value 9

Metadata

Release files for identicallist 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for identicallist 0.1.2
File Size Uploaded Provenance Actions
identicallist-0.1.2.tar.gz 2.7 kB Without provenance Details for identicallist-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for identicallist 0.1.2
File Interpreter ABI Platform Actions
identicallist-0.1.2-py3-none-any.whl Python 3 none any Details for identicallist-0.1.2-py3-none-any.whl

Total release size: 6.4 kB

Release files / identicallist-0.1.2.tar.gz

Download URL identicallist-0.1.2.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
07537c653eef69ee4499d1746df5060e78732154b1855c570a3c89dae6174774
BLAKE2b-256 checksum
How to use checksums
6b415e995b8643a9f7ae60002f598fcf38844a365b572d862891e1523a16dea6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.2

Release files / identicallist-0.1.2-py3-none-any.whl

Download URL identicallist-0.1.2-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08130949b1bc74f5f0b49badd897a28a56de5ee33426e76d917dbb5a7dd5c419
BLAKE2b-256 checksum
How to use checksums
4519ebd014591b7d6a932babff579b7f6d1aa6fcf5397a9737cef4dc2b394349
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.2

Security for identicallist 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page