Giter Site home page Giter Site logo

listo's Introduction

listo

Listo is an enhanced version of the list type that aims to do the following:

  • Make behavior more consistent. No more methods with "in-place" changes. Every method call returns a value
  • Adds methods that are missing from the list type. For example, listo has a first method that returns self[0]
  • A list of arguments passed in will be converted to a listo object, but a single argument that is an iterator will be unpacked into a listo object. This is useful for when you want to pass in a generator or other iterator into a function that expects a list

Usage

First install it via pip, poetry, or whatever you use

pip install listo

Then use it in your code

from listo import listo

lst = listo(1, 2, 3)
assert lst.first() == 1
assert lst.last() == 2

Usage: How listo handles initial arguments

For arguments passed in, it just converts them to a listo object

lst = listo(1, 2, 3)
assert lst == [1, 2, 3]

lst2 = listo([1, 2, 3]) # list is unpacked
assert lst2 == [1, 2, 3]

lst3 = listo((1, 2, 3)) # tuple is converted and unpacked
assert lst3 == [1, 2, 3]

lst4 = listo([1, 2, 3], (1, 2))  # Two args mean nothing is unpacked
assert lst4 == [[1, 2, 3], (1, 2)]

This is different from standard Python iterator behavior.

Contributing to Listo

Have you tried using Listo and found it useful? Do you have ideas for how to make it better?

We welcome contributions from the community!

See CONTRIBUTING.md for details on how to set up your development environment to contribute to this project, run tests, check code quality, release new versions, and more.

listo's People

Contributors

audreyfeldroy avatar misterrager8 avatar pydanny avatar yaswanthdasamandam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.