Coder Social home page Coder Social logo

more-ds's Introduction

More Data Structures

More Data Structures or more-ds for short, provides simple and convenient Python data structures.

Origin

The projected started with the need to extract the simplest of classes from an exitsting open source library, nwa-stdlib. That library primarily contained code that was rather specific to the organization that created the library. However, the URL class was a tiny convenience data structure, with broader applicability, that took the chore out of programmatically creating URLs. By extracting that class into a separate project, one that is specifically focussed on convenient data structures, it hopefully attracts a broader set of users that would otherwise don't feel comfortable including nwa-stdlib as a whole.

The project's name was inpired by the wonderful More Itertools library.

Data Structures

There is currently one data structure available (more to follow):

  • URL

URL

The URL class is a str (overrides it). Hence, can be used anywhere a regular string is used. It overrides two magical methods that correspond to the / and // operators.

The / operator is used to concatenate separate path components of a URL. The // operator is used to append a query string by supplying it with a dictionary.

An example should make this clear:

>>> from more_ds.network.url import URL
>>> base_url = URL("http://example.org/")
>>> api_url = base_url / "api"
>>> url = api_url / "ip" / "address" // dict(version=4)
>>> print(url)
http://example.org/api/ip/address?version=4

When adding path components, the / operator will insert or remove redundant slashes where necessary. The // automatically take cares of properly URL encoding the keys and values.

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.