Skip to main content

Use lists like you would dictionaries.

Project description

addressable is a silly little utility that allows you to access items inside of a list using one or more indices as keys. You pretty much get to pretend pretend that a list is a souped-up dictionary.

artists = [{
    'id': '0488',
    'name': 'Lambchop',
    'members': ['Kurt Wagner'],
}, {
    'id': '9924',
    'name': 'Dire Straits',
    'members': ['Mark Knopfler'],
}]

# keys are matched against one or more indices
artists = List(artists, indices=('id', 'name'))
print artists['0488'] == artists['Lambchop']

# fuzzy matching
artists = List(artists, indices=('id', 'title'), fuzzy=True)
print artists['strait']

# extract the value, not the metadata
artists = List(artists, indices=('id', 'title'), facet='title')
print artists['9924'] == 'Dire Straits'

So why would you want to do any of this? You probably don’t.

addressable can be useful for certain DSL or library code where you want to give the end users some freedom to code things their way, when you need to be able to very easily refer to certain things that are weirdly named or when there’s multiple common ways of referring to something and you want the flexibility to mix-and-match.

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

addressable-1.4.2.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file addressable-1.4.2.tar.gz.

File metadata

  • Download URL: addressable-1.4.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for addressable-1.4.2.tar.gz
Algorithm Hash digest
SHA256 09917d69d76affbfb833aeb09ecaa3836064249692337620a176748a9a826d0b
MD5 b8820675dc0749986013d65718887257
BLAKE2b-256 097c3aadb546b7704938386bed7e5c3022f53ab8556bacc6e655371bf83d3ae8

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