Skip to main content

Magic List

Logo

Palestine support banner

PyPI badge Downloads Tests Ruff Typechecking License: MIT

Magic List is a module that extends the built-in list type.

Documentation · PyPI package · How to install · Notes for contributors and maintainers

[!NOTE] Its development is entirely test-driven: it is battery-tested and requires a test coverage of 100%. It also provides type stubs.

Installation

pip install magic-list

Examples

Fibonacci sequence

Let's write a function that given an integer n, returns the fibonacci sequence up to the n-th member.

For example, fibonacci_sequence(10) would return [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55].

import operator

from magic_list import L, list

def fibonacci_sequence(n: int) -> list[int]:
    # let's start by creating a list with the first two members, 0 and 1.
    base = L[0, 1]

    # we define a function that we will use to generate the next members of
    # the sequence
    def next_member(current: list[int]) -> int:
        return current.take_right(2).sum()

    return base.fill_right(next_member, n - 1)

[!NOTE] The L[0, 1] notation is a way to construct magic lists nicely.

Contributing

First of all, thank you for taking your time to participate in this project! 💕

You might want to check those:

  • Code of Conduct · a document to set standards for respectful and inclusive behavior within the community
  • README-dev.md · documentation to help you familiarize with Magic List's workflow
  • Feature proposals · a list of the proposed features in the past, present and future

Release files for magic-list 2.4.0

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

Source distribution (sdist)

Source distribution for magic-list 2.4.0
File Size Uploaded
magic_list-2.4.0.tar.gz 13.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for magic-list 2.4.0
File Interpreter ABI Platform
magic_list-2.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.8 kB

Release files / magic_list-2.4.0.tar.gz

Download URL magic_list-2.4.0.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
63e202e0bd373cd4ecf2b56706121ff366ca3f1aef14d6966e1a5ce58cb75d80
BLAKE2b-256 checksum
How to use checksums
84eaf6abff0c396aac58f754551f099a57a2e995cc3358c81cd41ec0f6f71b8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19

Release files / magic_list-2.4.0-py3-none-any.whl

Download URL magic_list-2.4.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9b45988049b93c6d3705b9c438a2fdde35ff6651ac7c4bd4e57f6be8a251131
BLAKE2b-256 checksum
How to use checksums
fda9156b0773f6c717f60138096ea6e9a0a06501f0ff6eaba38708f434df16d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19

Release history Release notifications | RSS feed

This release

2.4.0 This release

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.0

2 release files

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